

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>O365.calendar &mdash; O365  documentation</title>
  

  
  
  
  

  

  
  
    

  

  <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" /> 

  
  <script src="../../_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="../../index.html" class="icon icon-home"> O365
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../getting_started.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../usage.html">Detailed Usage</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api.html">O365 API</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../index.html">O365</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../index.html">Docs</a> &raquo;</li>
        
          <li><a href="../index.html">Module code</a> &raquo;</li>
        
      <li>O365.calendar</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <h1>Source code for O365.calendar</h1><div class="highlight"><pre>
<span></span><span class="kn">import</span> <span class="nn">calendar</span>
<span class="kn">import</span> <span class="nn">datetime</span> <span class="k">as</span> <span class="nn">dt</span>
<span class="kn">import</span> <span class="nn">logging</span>

<span class="kn">import</span> <span class="nn">pytz</span>
<span class="c1"># noinspection PyPep8Naming</span>
<span class="kn">from</span> <span class="nn">bs4</span> <span class="kn">import</span> <span class="n">BeautifulSoup</span> <span class="k">as</span> <span class="n">bs</span>
<span class="kn">from</span> <span class="nn">dateutil.parser</span> <span class="kn">import</span> <span class="n">parse</span>

<span class="kn">from</span> <span class="nn">.utils</span> <span class="kn">import</span> <span class="n">CaseEnum</span>
<span class="kn">from</span> <span class="nn">.utils</span> <span class="kn">import</span> <span class="n">HandleRecipientsMixin</span>
<span class="kn">from</span> <span class="nn">.utils</span> <span class="kn">import</span> <span class="n">AttachableMixin</span><span class="p">,</span> <span class="n">ImportanceLevel</span><span class="p">,</span> <span class="n">TrackerSet</span>
<span class="kn">from</span> <span class="nn">.utils</span> <span class="kn">import</span> <span class="n">BaseAttachments</span><span class="p">,</span> <span class="n">BaseAttachment</span>
<span class="kn">from</span> <span class="nn">.utils</span> <span class="kn">import</span> <span class="n">Pagination</span><span class="p">,</span> <span class="n">NEXT_LINK_KEYWORD</span><span class="p">,</span> <span class="n">ApiComponent</span>
<span class="kn">from</span> <span class="nn">.utils.windows_tz</span> <span class="kn">import</span> <span class="n">get_windows_tz</span>
<span class="kn">from</span> <span class="nn">.category</span> <span class="kn">import</span> <span class="n">Category</span>

<span class="n">log</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>

<span class="n">MONTH_NAMES</span> <span class="o">=</span> <span class="p">[</span><span class="n">calendar</span><span class="o">.</span><span class="n">month_name</span><span class="p">[</span><span class="n">x</span><span class="p">]</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">13</span><span class="p">)]</span>


<div class="viewcode-block" id="EventResponse"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.EventResponse">[docs]</a><span class="k">class</span> <span class="nc">EventResponse</span><span class="p">(</span><span class="n">CaseEnum</span><span class="p">):</span>
    <span class="n">Organizer</span> <span class="o">=</span> <span class="s1">&#39;organizer&#39;</span>
    <span class="n">TentativelyAccepted</span> <span class="o">=</span> <span class="s1">&#39;tentativelyAccepted&#39;</span>
    <span class="n">Accepted</span> <span class="o">=</span> <span class="s1">&#39;accepted&#39;</span>
    <span class="n">Declined</span> <span class="o">=</span> <span class="s1">&#39;declined&#39;</span>
    <span class="n">NotResponded</span> <span class="o">=</span> <span class="s1">&#39;notResponded&#39;</span></div>


<div class="viewcode-block" id="AttendeeType"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.AttendeeType">[docs]</a><span class="k">class</span> <span class="nc">AttendeeType</span><span class="p">(</span><span class="n">CaseEnum</span><span class="p">):</span>
    <span class="n">Required</span> <span class="o">=</span> <span class="s1">&#39;required&#39;</span>
    <span class="n">Optional</span> <span class="o">=</span> <span class="s1">&#39;optional&#39;</span>
    <span class="n">Resource</span> <span class="o">=</span> <span class="s1">&#39;resource&#39;</span></div>


<div class="viewcode-block" id="EventSensitivity"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.EventSensitivity">[docs]</a><span class="k">class</span> <span class="nc">EventSensitivity</span><span class="p">(</span><span class="n">CaseEnum</span><span class="p">):</span>
    <span class="n">Normal</span> <span class="o">=</span> <span class="s1">&#39;normal&#39;</span>
    <span class="n">Personal</span> <span class="o">=</span> <span class="s1">&#39;personal&#39;</span>
    <span class="n">Private</span> <span class="o">=</span> <span class="s1">&#39;private&#39;</span>
    <span class="n">Confidential</span> <span class="o">=</span> <span class="s1">&#39;confidential&#39;</span></div>


<div class="viewcode-block" id="EventShowAs"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.EventShowAs">[docs]</a><span class="k">class</span> <span class="nc">EventShowAs</span><span class="p">(</span><span class="n">CaseEnum</span><span class="p">):</span>
    <span class="n">Free</span> <span class="o">=</span> <span class="s1">&#39;free&#39;</span>
    <span class="n">Tentative</span> <span class="o">=</span> <span class="s1">&#39;tentative&#39;</span>
    <span class="n">Busy</span> <span class="o">=</span> <span class="s1">&#39;busy&#39;</span>
    <span class="n">Oof</span> <span class="o">=</span> <span class="s1">&#39;oof&#39;</span>
    <span class="n">WorkingElsewhere</span> <span class="o">=</span> <span class="s1">&#39;workingElsewhere&#39;</span>
    <span class="n">Unknown</span> <span class="o">=</span> <span class="s1">&#39;unknown&#39;</span></div>


<div class="viewcode-block" id="CalendarColor"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.CalendarColor">[docs]</a><span class="k">class</span> <span class="nc">CalendarColor</span><span class="p">(</span><span class="n">CaseEnum</span><span class="p">):</span>
    <span class="n">LightBlue</span> <span class="o">=</span> <span class="s1">&#39;lightBlue&#39;</span>
    <span class="n">LightGreen</span> <span class="o">=</span> <span class="s1">&#39;lightGreen&#39;</span>
    <span class="n">LightOrange</span> <span class="o">=</span> <span class="s1">&#39;lightOrange&#39;</span>
    <span class="n">LightGray</span> <span class="o">=</span> <span class="s1">&#39;lightGray&#39;</span>
    <span class="n">LightYellow</span> <span class="o">=</span> <span class="s1">&#39;lightYellow&#39;</span>
    <span class="n">LightTeal</span> <span class="o">=</span> <span class="s1">&#39;lightTeal&#39;</span>
    <span class="n">LightPink</span> <span class="o">=</span> <span class="s1">&#39;lightPink&#39;</span>
    <span class="n">LightBrown</span> <span class="o">=</span> <span class="s1">&#39;lightBrown&#39;</span>
    <span class="n">LightRed</span> <span class="o">=</span> <span class="s1">&#39;lightRed&#39;</span>
    <span class="n">MaxColor</span> <span class="o">=</span> <span class="s1">&#39;maxColor&#39;</span>
    <span class="n">Auto</span> <span class="o">=</span> <span class="s1">&#39;auto&#39;</span></div>


<div class="viewcode-block" id="EventType"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.EventType">[docs]</a><span class="k">class</span> <span class="nc">EventType</span><span class="p">(</span><span class="n">CaseEnum</span><span class="p">):</span>
    <span class="n">SingleInstance</span> <span class="o">=</span> <span class="s1">&#39;singleInstance&#39;</span>  <span class="c1"># a normal (non-recurring) event</span>
    <span class="n">Occurrence</span> <span class="o">=</span> <span class="s1">&#39;occurrence&#39;</span>  <span class="c1"># all the other recurring events that is not the first one (seriesMaster)</span>
    <span class="ne">Exception</span> <span class="o">=</span> <span class="s1">&#39;exception&#39;</span>  <span class="c1"># ?</span>
    <span class="n">SeriesMaster</span> <span class="o">=</span> <span class="s1">&#39;seriesMaster&#39;</span>  <span class="c1"># the first recurring event of the series</span></div>

<div class="viewcode-block" id="OnlineMeetingProviderType"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.OnlineMeetingProviderType">[docs]</a><span class="k">class</span> <span class="nc">OnlineMeetingProviderType</span><span class="p">(</span><span class="n">CaseEnum</span><span class="p">):</span>
    <span class="n">Unknown</span> <span class="o">=</span> <span class="s1">&#39;unknown&#39;</span>
    <span class="n">TeamsForBusiness</span> <span class="o">=</span> <span class="s1">&#39;teamsForBusiness&#39;</span>
    <span class="n">SkypeForBusiness</span> <span class="o">=</span> <span class="s1">&#39;skypeForBusiness&#39;</span>
    <span class="n">SkypeForConsumer</span> <span class="o">=</span> <span class="s1">&#39;skypeForConsumer&#39;</span></div>

<div class="viewcode-block" id="EventAttachment"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.EventAttachment">[docs]</a><span class="k">class</span> <span class="nc">EventAttachment</span><span class="p">(</span><span class="n">BaseAttachment</span><span class="p">):</span>
    <span class="n">_endpoints</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;attach&#39;</span><span class="p">:</span> <span class="s1">&#39;/events/</span><span class="si">{id}</span><span class="s1">/attachments&#39;</span><span class="p">}</span></div>


<div class="viewcode-block" id="EventAttachments"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.EventAttachments">[docs]</a><span class="k">class</span> <span class="nc">EventAttachments</span><span class="p">(</span><span class="n">BaseAttachments</span><span class="p">):</span>
    <span class="n">_endpoints</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;attachments&#39;</span><span class="p">:</span> <span class="s1">&#39;/events/</span><span class="si">{id}</span><span class="s1">/attachments&#39;</span><span class="p">}</span>

    <span class="n">_attachment_constructor</span> <span class="o">=</span> <span class="n">EventAttachment</span></div>


<div class="viewcode-block" id="DailyEventFrequency"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.DailyEventFrequency">[docs]</a><span class="k">class</span> <span class="nc">DailyEventFrequency</span><span class="p">:</span>
<div class="viewcode-block" id="DailyEventFrequency.__init__"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.DailyEventFrequency.__init__">[docs]</a>    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">recurrence_type</span><span class="p">,</span> <span class="n">interval</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">recurrence_type</span> <span class="o">=</span> <span class="n">recurrence_type</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">interval</span> <span class="o">=</span> <span class="n">interval</span></div></div>


<span class="c1"># noinspection PyAttributeOutsideInit</span>
<div class="viewcode-block" id="EventRecurrence"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.EventRecurrence">[docs]</a><span class="k">class</span> <span class="nc">EventRecurrence</span><span class="p">(</span><span class="n">ApiComponent</span><span class="p">):</span>
<div class="viewcode-block" id="EventRecurrence.__init__"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.EventRecurrence.__init__">[docs]</a>    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">event</span><span class="p">,</span> <span class="n">recurrence</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; A representation of an event recurrence properties</span>

<span class="sd">        :param Event event: event object</span>
<span class="sd">        :param dict recurrence: recurrence information</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">protocol</span><span class="o">=</span><span class="n">event</span><span class="o">.</span><span class="n">protocol</span><span class="p">,</span>
                         <span class="n">main_resource</span><span class="o">=</span><span class="n">event</span><span class="o">.</span><span class="n">main_resource</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_event</span> <span class="o">=</span> <span class="n">event</span>
        <span class="n">recurrence</span> <span class="o">=</span> <span class="n">recurrence</span> <span class="ow">or</span> <span class="p">{}</span>
        <span class="c1"># recurrence pattern</span>
        <span class="n">recurrence_pattern</span> <span class="o">=</span> <span class="n">recurrence</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;pattern&#39;</span><span class="p">),</span> <span class="p">{})</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">__interval</span> <span class="o">=</span> <span class="n">recurrence_pattern</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;interval&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__days_of_week</span> <span class="o">=</span> <span class="n">recurrence_pattern</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;daysOfWeek&#39;</span><span class="p">),</span>
                                                     <span class="nb">set</span><span class="p">())</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__first_day_of_week</span> <span class="o">=</span> <span class="n">recurrence_pattern</span><span class="o">.</span><span class="n">get</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;firstDayOfWeek&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span>
        <span class="k">if</span> <span class="s1">&#39;type&#39;</span> <span class="ow">in</span> <span class="n">recurrence_pattern</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
            <span class="k">if</span> <span class="s1">&#39;weekly&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">recurrence_pattern</span><span class="p">[</span><span class="s1">&#39;type&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">():</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">__first_day_of_week</span> <span class="o">=</span> <span class="kc">None</span>
                
        <span class="bp">self</span><span class="o">.</span><span class="n">__day_of_month</span> <span class="o">=</span> <span class="n">recurrence_pattern</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;dayOfMonth&#39;</span><span class="p">),</span>
                                                     <span class="kc">None</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__month</span> <span class="o">=</span> <span class="n">recurrence_pattern</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;month&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__index</span> <span class="o">=</span> <span class="n">recurrence_pattern</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;index&#39;</span><span class="p">),</span> <span class="s1">&#39;first&#39;</span><span class="p">)</span>

        <span class="c1"># recurrence range</span>
        <span class="n">recurrence_range</span> <span class="o">=</span> <span class="n">recurrence</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;range&#39;</span><span class="p">),</span> <span class="p">{})</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">__occurrences</span> <span class="o">=</span> <span class="n">recurrence_range</span><span class="o">.</span><span class="n">get</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;numberOfOccurrences&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__start_date</span> <span class="o">=</span> <span class="n">recurrence_range</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;startDate&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__end_date</span> <span class="o">=</span> <span class="n">recurrence_range</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;endDate&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__recurrence_time_zone</span> <span class="o">=</span> <span class="n">recurrence_range</span><span class="o">.</span><span class="n">get</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;recurrenceTimeZone&#39;</span><span class="p">),</span>
            <span class="n">get_windows_tz</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">protocol</span><span class="o">.</span><span class="n">timezone</span><span class="p">))</span>
        <span class="c1"># time and time zones are not considered in recurrence ranges...</span>
        <span class="c1"># I don&#39;t know why &#39;recurrenceTimeZone&#39; is present here</span>
        <span class="c1"># Sending a startDate datetime to the server results in an Error:</span>
        <span class="c1"># Cannot convert the literal &#39;datetime&#39; to the expected type &#39;Edm.Date&#39;</span>
        <span class="k">if</span> <span class="n">recurrence_range</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">__start_date</span> <span class="o">=</span> <span class="n">parse</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">__start_date</span><span class="p">)</span><span class="o">.</span><span class="n">date</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__start_date</span> <span class="k">else</span> <span class="kc">None</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">__end_date</span> <span class="o">=</span> <span class="n">parse</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">__end_date</span><span class="p">)</span><span class="o">.</span><span class="n">date</span><span class="p">()</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__end_date</span> <span class="k">else</span> <span class="kc">None</span></div>

    <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__interval</span><span class="p">:</span>
            <span class="n">pattern</span> <span class="o">=</span> <span class="s1">&#39;Daily: every </span><span class="si">{}</span><span class="s1"> day/s&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__interval</span><span class="p">)</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__days_of_week</span><span class="p">:</span>
                <span class="n">days</span> <span class="o">=</span> <span class="s1">&#39; or &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__days_of_week</span><span class="p">))</span>
                <span class="n">pattern</span> <span class="o">=</span> <span class="s1">&#39;Relative Monthly: </span><span class="si">{}</span><span class="s1"> </span><span class="si">{}</span><span class="s1"> every </span><span class="si">{}</span><span class="s1"> month/s&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">__index</span><span class="p">,</span> <span class="n">days</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">__interval</span><span class="p">)</span>
                <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__first_day_of_week</span><span class="p">:</span>
                    <span class="n">pattern</span> <span class="o">=</span> <span class="s1">&#39;Weekly: every </span><span class="si">{}</span><span class="s1"> week/s on </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">__interval</span><span class="p">,</span> <span class="n">days</span><span class="p">)</span>
                <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">__month</span><span class="p">:</span>
                    <span class="n">pattern</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;Relative Yearly: </span><span class="si">{}</span><span class="s1"> </span><span class="si">{}</span><span class="s1"> every </span><span class="si">{}</span><span class="s1"> year/s on </span><span class="si">{}</span><span class="s1">&#39;</span>
                               <span class="s1">&#39;&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__index</span><span class="p">,</span> <span class="n">days</span><span class="p">,</span>
                                         <span class="bp">self</span><span class="o">.</span><span class="n">__interval</span><span class="p">,</span>
                                         <span class="n">MONTH_NAMES</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">__month</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]))</span>
            <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">__day_of_month</span><span class="p">:</span>
                <span class="n">pattern</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;Absolute Monthly: on day </span><span class="si">{}</span><span class="s1"> every </span><span class="si">{}</span><span class="s1"> month/s&#39;</span>
                           <span class="s1">&#39;&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__day_of_month</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">__interval</span><span class="p">))</span>
                <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__month</span><span class="p">:</span>
                    <span class="n">pattern</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;Absolute Yearly: on </span><span class="si">{}</span><span class="s1"> </span><span class="si">{}</span><span class="s1"> every </span><span class="si">{}</span><span class="s1"> year/s&#39;</span>
                               <span class="s1">&#39;&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">MONTH_NAMES</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">__month</span> <span class="o">-</span> <span class="mi">1</span><span class="p">],</span>
                                         <span class="bp">self</span><span class="o">.</span><span class="n">__day_of_month</span><span class="p">,</span>
                                         <span class="bp">self</span><span class="o">.</span><span class="n">__interval</span><span class="p">))</span>

            <span class="n">r_range</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__start_date</span><span class="p">:</span>
                <span class="n">r_range</span> <span class="o">=</span> <span class="s1">&#39;Starting on </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__start_date</span><span class="p">)</span>
                <span class="n">ends_on</span> <span class="o">=</span> <span class="s1">&#39;with no end&#39;</span>
                <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__end_date</span><span class="p">:</span>
                    <span class="n">ends_on</span> <span class="o">=</span> <span class="s1">&#39;ending on </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__end_date</span><span class="p">)</span>
                <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">__occurrences</span><span class="p">:</span>
                    <span class="n">ends_on</span> <span class="o">=</span> <span class="s1">&#39;up to </span><span class="si">{}</span><span class="s1"> occurrences&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__occurrences</span><span class="p">)</span>
                <span class="n">r_range</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">{}</span><span class="s1"> </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">r_range</span><span class="p">,</span> <span class="n">ends_on</span><span class="p">)</span>
            <span class="k">return</span> <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">. </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">pattern</span><span class="p">,</span> <span class="n">r_range</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="s1">&#39;No recurrence enabled&#39;</span>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="fm">__repr__</span><span class="p">()</span>

    <span class="k">def</span> <span class="fm">__bool__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="nb">bool</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__interval</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_track_changes</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Update the track_changes on the event to reflect a needed</span>
<span class="sd">        update on this field &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_event</span><span class="o">.</span><span class="n">_track_changes</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s1">&#39;recurrence&#39;</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">interval</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Repeat interval for the event</span>

<span class="sd">        :getter: Get the current interval</span>
<span class="sd">        :setter: Update to a new interval</span>
<span class="sd">        :type: int</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__interval</span>

    <span class="nd">@interval</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">interval</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__interval</span> <span class="o">=</span> <span class="n">value</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="p">()</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">days_of_week</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Days in week to repeat</span>

<span class="sd">        :getter: Get the current list of days</span>
<span class="sd">        :setter: Set the list of days to repeat</span>
<span class="sd">        :type: set(str)</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__days_of_week</span>

    <span class="nd">@days_of_week</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">days_of_week</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__days_of_week</span> <span class="o">=</span> <span class="n">value</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="p">()</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">first_day_of_week</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Which day to consider start of the week</span>

<span class="sd">        :getter: Get the current start of week</span>
<span class="sd">        :setter: Set the start day of week</span>
<span class="sd">        :type: str</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__first_day_of_week</span>

    <span class="nd">@first_day_of_week</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">first_day_of_week</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__first_day_of_week</span> <span class="o">=</span> <span class="n">value</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="p">()</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">day_of_month</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Repeat on this day of month</span>

<span class="sd">        :getter: Get the repeat day of month</span>
<span class="sd">        :setter: Set the repeat day of month</span>
<span class="sd">        :type: int</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__day_of_month</span>

    <span class="nd">@day_of_month</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">day_of_month</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__day_of_month</span> <span class="o">=</span> <span class="n">value</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="p">()</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">month</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Month of the event</span>

<span class="sd">        :getter: Get month</span>
<span class="sd">        :setter: Update month</span>
<span class="sd">        :type: int</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__month</span>

    <span class="nd">@month</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">month</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__month</span> <span class="o">=</span> <span class="n">value</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="p">()</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">index</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Index</span>

<span class="sd">        :getter: Get index</span>
<span class="sd">        :setter: Set index</span>
<span class="sd">        :type: str</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__index</span>

    <span class="nd">@index</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">index</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__index</span> <span class="o">=</span> <span class="n">value</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="p">()</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">occurrences</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; No. of occurrences</span>

<span class="sd">        :getter: Get the no. of occurrences</span>
<span class="sd">        :setter: Set the no. of occurrences</span>
<span class="sd">        :type: int</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__occurrences</span>

    <span class="nd">@occurrences</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">occurrences</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__occurrences</span> <span class="o">=</span> <span class="n">value</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="p">()</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">recurrence_time_zone</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Timezone to consider for repeating</span>

<span class="sd">        :getter: Get the timezone</span>
<span class="sd">        :setter: Set the timezone</span>
<span class="sd">        :type: str</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__recurrence_time_zone</span>

    <span class="nd">@recurrence_time_zone</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">recurrence_time_zone</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__recurrence_time_zone</span> <span class="o">=</span> <span class="n">value</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="p">()</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">start_date</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Start date of repetition</span>

<span class="sd">        :getter: get the start date</span>
<span class="sd">        :setter: set the start date</span>
<span class="sd">        :type: date</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__start_date</span>

    <span class="nd">@start_date</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">start_date</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">dt</span><span class="o">.</span><span class="n">date</span><span class="p">):</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;start_date value must be a valid date object&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">dt</span><span class="o">.</span><span class="n">datetime</span><span class="p">):</span>
            <span class="n">value</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">date</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__start_date</span> <span class="o">=</span> <span class="n">value</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="p">()</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">end_date</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; End date of repetition</span>

<span class="sd">        :getter: get the end date</span>
<span class="sd">        :setter: set the end date</span>
<span class="sd">        :type: date</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__end_date</span>

    <span class="nd">@end_date</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">end_date</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">dt</span><span class="o">.</span><span class="n">date</span><span class="p">):</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;end_date value must be a valid date object&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">dt</span><span class="o">.</span><span class="n">datetime</span><span class="p">):</span>
            <span class="n">value</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">date</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__end_date</span> <span class="o">=</span> <span class="n">value</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="p">()</span>

<div class="viewcode-block" id="EventRecurrence.to_api_data"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.EventRecurrence.to_api_data">[docs]</a>    <span class="k">def</span> <span class="nf">to_api_data</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Returns a dict to communicate with the server</span>

<span class="sd">        :rtype: dict</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">data</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="c1"># recurrence pattern</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__interval</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__interval</span><span class="p">,</span> <span class="nb">int</span><span class="p">):</span>
            <span class="n">recurrence_pattern</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;pattern&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="n">recurrence_pattern</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;type&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="s1">&#39;daily&#39;</span>
            <span class="n">recurrence_pattern</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;interval&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__interval</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__days_of_week</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__days_of_week</span><span class="p">,</span>
                                                  <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">,</span> <span class="nb">set</span><span class="p">)):</span>
                <span class="n">recurrence_pattern</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;type&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="s1">&#39;relativeMonthly&#39;</span>
                <span class="n">recurrence_pattern</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;daysOfWeek&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">__days_of_week</span><span class="p">)</span>
                <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__first_day_of_week</span><span class="p">:</span>
                    <span class="n">recurrence_pattern</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;type&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="s1">&#39;weekly&#39;</span>
                    <span class="n">recurrence_pattern</span><span class="p">[</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;firstDayOfWeek&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__first_day_of_week</span>
                <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">__month</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__month</span><span class="p">,</span> <span class="nb">int</span><span class="p">):</span>
                    <span class="n">recurrence_pattern</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;type&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="s1">&#39;relativeYearly&#39;</span>
                    <span class="n">recurrence_pattern</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;month&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__month</span>
                    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__index</span><span class="p">:</span>
                        <span class="n">recurrence_pattern</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;index&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__index</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__index</span><span class="p">:</span>
                        <span class="n">recurrence_pattern</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;index&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__index</span>

            <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">__day_of_month</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__day_of_month</span><span class="p">,</span> <span class="nb">int</span><span class="p">):</span>
                <span class="n">recurrence_pattern</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;type&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="s1">&#39;absoluteMonthly&#39;</span>
                <span class="n">recurrence_pattern</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;dayOfMonth&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__day_of_month</span>
                <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__month</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__month</span><span class="p">,</span> <span class="nb">int</span><span class="p">):</span>
                    <span class="n">recurrence_pattern</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;type&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="s1">&#39;absoluteYearly&#39;</span>
                    <span class="n">recurrence_pattern</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;month&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__month</span>

        <span class="c1"># recurrence range</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__start_date</span><span class="p">:</span>
            <span class="n">recurrence_range</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;range&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="n">recurrence_range</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;type&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="s1">&#39;noEnd&#39;</span>
            <span class="n">recurrence_range</span><span class="p">[</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;startDate&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__start_date</span><span class="o">.</span><span class="n">isoformat</span><span class="p">()</span>
            <span class="n">recurrence_range</span><span class="p">[</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;recurrenceTimeZone&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__recurrence_time_zone</span>

            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__end_date</span><span class="p">:</span>
                <span class="n">recurrence_range</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;type&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="s1">&#39;endDate&#39;</span>
                <span class="n">recurrence_range</span><span class="p">[</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;endDate&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__end_date</span><span class="o">.</span><span class="n">isoformat</span><span class="p">()</span>
            <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">__occurrences</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">__occurrences</span><span class="p">,</span>
                    <span class="nb">int</span><span class="p">):</span>
                <span class="n">recurrence_range</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;type&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="s1">&#39;numbered&#39;</span>
                <span class="n">recurrence_range</span><span class="p">[</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;numberOfOccurrences&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__occurrences</span>

        <span class="k">return</span> <span class="n">data</span></div>

    <span class="k">def</span> <span class="nf">_clear_pattern</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Clears this event recurrence &quot;&quot;&quot;</span>
        <span class="c1"># pattern group</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__interval</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__days_of_week</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__first_day_of_week</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__day_of_month</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__month</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__index</span> <span class="o">=</span> <span class="s1">&#39;first&#39;</span>
        <span class="c1"># range group</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__start_date</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__end_date</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__occurrences</span> <span class="o">=</span> <span class="kc">None</span>

<div class="viewcode-block" id="EventRecurrence.set_range"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.EventRecurrence.set_range">[docs]</a>    <span class="k">def</span> <span class="nf">set_range</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">start</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">end</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">occurrences</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Set the range of recurrence</span>

<span class="sd">        :param date start: Start date of repetition</span>
<span class="sd">        :param date end: End date of repetition</span>
<span class="sd">        :param int occurrences: no of occurrences</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">start</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__start_date</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">__start_date</span> <span class="o">=</span> <span class="n">dt</span><span class="o">.</span><span class="n">date</span><span class="o">.</span><span class="n">today</span><span class="p">()</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">start_date</span> <span class="o">=</span> <span class="n">start</span>

        <span class="k">if</span> <span class="n">end</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">end_date</span> <span class="o">=</span> <span class="n">end</span>
        <span class="k">elif</span> <span class="n">occurrences</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">__occurrences</span> <span class="o">=</span> <span class="n">occurrences</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="p">()</span></div>

<div class="viewcode-block" id="EventRecurrence.set_daily"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.EventRecurrence.set_daily">[docs]</a>    <span class="k">def</span> <span class="nf">set_daily</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">interval</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Set to repeat every x no. of days</span>

<span class="sd">        :param int interval: no. of days to repeat at</span>
<span class="sd">        :keyword date start: Start date of repetition (kwargs)</span>
<span class="sd">        :keyword date end: End date of repetition (kwargs)</span>
<span class="sd">        :keyword int occurrences: no of occurrences (kwargs)</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_clear_pattern</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__interval</span> <span class="o">=</span> <span class="n">interval</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">set_range</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>

<div class="viewcode-block" id="EventRecurrence.set_weekly"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.EventRecurrence.set_weekly">[docs]</a>    <span class="k">def</span> <span class="nf">set_weekly</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">interval</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">days_of_week</span><span class="p">,</span> <span class="n">first_day_of_week</span><span class="p">,</span>
                   <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Set to repeat every week on specified days for every x no. of days</span>

<span class="sd">        :param int interval: no. of days to repeat at</span>
<span class="sd">        :param str first_day_of_week: starting day for a week</span>
<span class="sd">        :param list[str] days_of_week: list of days of the week to repeat</span>
<span class="sd">        :keyword date start: Start date of repetition (kwargs)</span>
<span class="sd">        :keyword date end: End date of repetition (kwargs)</span>
<span class="sd">        :keyword int occurrences: no of occurrences (kwargs)</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">set_daily</span><span class="p">(</span><span class="n">interval</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__days_of_week</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">days_of_week</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__first_day_of_week</span> <span class="o">=</span> <span class="n">first_day_of_week</span></div>

<div class="viewcode-block" id="EventRecurrence.set_monthly"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.EventRecurrence.set_monthly">[docs]</a>    <span class="k">def</span> <span class="nf">set_monthly</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">interval</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">day_of_month</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">days_of_week</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                    <span class="n">index</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Set to repeat every month on specified days for every x no. of days</span>

<span class="sd">        :param int interval: no. of days to repeat at</span>
<span class="sd">        :param int day_of_month: repeat day of a month</span>
<span class="sd">        :param list[str] days_of_week: list of days of the week to repeat</span>
<span class="sd">        :param index: index</span>
<span class="sd">        :keyword date start: Start date of repetition (kwargs)</span>
<span class="sd">        :keyword date end: End date of repetition (kwargs)</span>
<span class="sd">        :keyword int occurrences: no of occurrences (kwargs)</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">day_of_month</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">days_of_week</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;Must provide day_of_month or days_of_week values&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">day_of_month</span> <span class="ow">and</span> <span class="n">days_of_week</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;Must provide only one of the two options&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">set_daily</span><span class="p">(</span><span class="n">interval</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">day_of_month</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">__day_of_month</span> <span class="o">=</span> <span class="n">day_of_month</span>
        <span class="k">elif</span> <span class="n">days_of_week</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">__days_of_week</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">days_of_week</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">index</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">__index</span> <span class="o">=</span> <span class="n">index</span></div>

<div class="viewcode-block" id="EventRecurrence.set_yearly"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.EventRecurrence.set_yearly">[docs]</a>    <span class="k">def</span> <span class="nf">set_yearly</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">interval</span><span class="p">,</span> <span class="n">month</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">day_of_month</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                   <span class="n">days_of_week</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">index</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Set to repeat every month on specified days for every x no. of days</span>

<span class="sd">        :param int interval: no. of days to repeat at</span>
<span class="sd">        :param int month: month to repeat</span>
<span class="sd">        :param int day_of_month: repeat day of a month</span>
<span class="sd">        :param list[str] days_of_week: list of days of the week to repeat</span>
<span class="sd">        :param index: index</span>
<span class="sd">        :keyword date start: Start date of repetition (kwargs)</span>
<span class="sd">        :keyword date end: End date of repetition (kwargs)</span>
<span class="sd">        :keyword int occurrences: no of occurrences (kwargs)</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">set_monthly</span><span class="p">(</span><span class="n">interval</span><span class="p">,</span> <span class="n">day_of_month</span><span class="o">=</span><span class="n">day_of_month</span><span class="p">,</span>
                         <span class="n">days_of_week</span><span class="o">=</span><span class="n">days_of_week</span><span class="p">,</span> <span class="n">index</span><span class="o">=</span><span class="n">index</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__month</span> <span class="o">=</span> <span class="n">month</span></div></div>


<div class="viewcode-block" id="ResponseStatus"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.ResponseStatus">[docs]</a><span class="k">class</span> <span class="nc">ResponseStatus</span><span class="p">(</span><span class="n">ApiComponent</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; An event response status (status, time) &quot;&quot;&quot;</span>

<div class="viewcode-block" id="ResponseStatus.__init__"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.ResponseStatus.__init__">[docs]</a>    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parent</span><span class="p">,</span> <span class="n">response_status</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; An event response status (status, time)</span>

<span class="sd">        :param parent: parent of this</span>
<span class="sd">        :type parent: Attendees or Event</span>
<span class="sd">        :param dict response_status: status info frm cloud</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">protocol</span><span class="o">=</span><span class="n">parent</span><span class="o">.</span><span class="n">protocol</span><span class="p">,</span>
                         <span class="n">main_resource</span><span class="o">=</span><span class="n">parent</span><span class="o">.</span><span class="n">main_resource</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">status</span> <span class="o">=</span> <span class="n">response_status</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;response&#39;</span><span class="p">),</span> <span class="s1">&#39;none&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">status</span> <span class="o">=</span> <span class="kc">None</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">status</span> <span class="o">==</span> <span class="s1">&#39;none&#39;</span> <span class="k">else</span> <span class="n">EventResponse</span><span class="o">.</span><span class="n">from_value</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">status</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">status</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">response_time</span> <span class="o">=</span> <span class="n">response_status</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;time&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">response_time</span> <span class="o">==</span> <span class="s1">&#39;0001-01-01T00:00:00Z&#39;</span><span class="p">:</span>
                <span class="c1"># consider there&#39;s no response time</span>
                <span class="c1"># this way we don&#39;t try to convert this Iso 8601 datetime to the</span>
                <span class="c1">#  local timezone which generated parse errors</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">response_time</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">response_time</span><span class="p">:</span>
                <span class="k">try</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">response_time</span> <span class="o">=</span> <span class="n">parse</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">response_time</span><span class="p">)</span><span class="o">.</span><span class="n">astimezone</span><span class="p">(</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">protocol</span><span class="o">.</span><span class="n">timezone</span><span class="p">)</span>
                <span class="k">except</span> <span class="ne">OverflowError</span><span class="p">:</span>
                    <span class="n">log</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Couldn&#39;t parse event response time: </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">response_time</span><span class="p">))</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">response_time</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">response_time</span> <span class="o">=</span> <span class="kc">None</span></div>

    <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">status</span> <span class="ow">or</span> <span class="s1">&#39;None&#39;</span>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="fm">__repr__</span><span class="p">()</span></div>


<div class="viewcode-block" id="Attendee"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Attendee">[docs]</a><span class="k">class</span> <span class="nc">Attendee</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot; A Event attendee &quot;&quot;&quot;</span>

<div class="viewcode-block" id="Attendee.__init__"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Attendee.__init__">[docs]</a>    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">address</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">attendee_type</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                 <span class="n">response_status</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">event</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Create a event attendee</span>

<span class="sd">        :param str address: email address of the attendee</span>
<span class="sd">        :param str name: name of the attendee</span>
<span class="sd">        :param AttendeeType attendee_type: requirement of attendee</span>
<span class="sd">        :param Response response_status: response status requirement</span>
<span class="sd">        :param Event event: event for which to assign the attendee</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_untrack</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_address</span> <span class="o">=</span> <span class="n">address</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_name</span> <span class="o">=</span> <span class="n">name</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_event</span> <span class="o">=</span> <span class="n">event</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">response_status</span><span class="p">,</span> <span class="n">ResponseStatus</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">__response_status</span> <span class="o">=</span> <span class="n">response_status</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">__response_status</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__attendee_type</span> <span class="o">=</span> <span class="n">AttendeeType</span><span class="o">.</span><span class="n">Required</span>
        <span class="k">if</span> <span class="n">attendee_type</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">attendee_type</span> <span class="o">=</span> <span class="n">attendee_type</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_untrack</span> <span class="o">=</span> <span class="kc">False</span></div>

    <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">:</span>
            <span class="k">return</span> <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">: </span><span class="si">{}</span><span class="s1"> (</span><span class="si">{}</span><span class="s1">)&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">attendee_type</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span>
                                        <span class="bp">self</span><span class="o">.</span><span class="n">address</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="s1">&#39;</span><span class="si">{}</span><span class="s1">: </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">attendee_type</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">address</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="fm">__repr__</span><span class="p">()</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">address</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Email address</span>

<span class="sd">        :getter: Get the email address of attendee</span>
<span class="sd">        :setter: Set the email address of attendee</span>
<span class="sd">        :type: str</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_address</span>

    <span class="nd">@address</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">address</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_address</span> <span class="o">=</span> <span class="n">value</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_name</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="p">()</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Name</span>

<span class="sd">        :getter: Get the name of attendee</span>
<span class="sd">        :setter: Set the name of attendee</span>
<span class="sd">        :type: str</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_name</span>

    <span class="nd">@name</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">name</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_name</span> <span class="o">=</span> <span class="n">value</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">_track_changes</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Update the track_changes on the event to reflect a</span>
<span class="sd">        needed update on this field &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_untrack</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_event</span><span class="o">.</span><span class="n">_track_changes</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s1">&#39;attendees&#39;</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">response_status</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Response status of the attendee</span>

<span class="sd">        :type: ResponseStatus</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__response_status</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">attendee_type</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Requirement of the attendee</span>

<span class="sd">        :getter: Get the requirement of attendee</span>
<span class="sd">        :setter: Set the requirement of attendee</span>
<span class="sd">        :type: AttendeeType</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__attendee_type</span>

    <span class="nd">@attendee_type</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">attendee_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">AttendeeType</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">__attendee_type</span> <span class="o">=</span> <span class="n">value</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">__attendee_type</span> <span class="o">=</span> <span class="n">AttendeeType</span><span class="o">.</span><span class="n">from_value</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="p">()</span></div>


<div class="viewcode-block" id="Attendees"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Attendees">[docs]</a><span class="k">class</span> <span class="nc">Attendees</span><span class="p">(</span><span class="n">ApiComponent</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; A Collection of Attendees &quot;&quot;&quot;</span>

<div class="viewcode-block" id="Attendees.__init__"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Attendees.__init__">[docs]</a>    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">event</span><span class="p">,</span> <span class="n">attendees</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Create a collection of attendees</span>

<span class="sd">        :param Event event: event for which to assign the attendees</span>
<span class="sd">        :param attendees: list of attendees to add</span>
<span class="sd">        :type attendees: str or tuple(str, str) or Attendee or list[str] or</span>
<span class="sd">         list[tuple(str,str)] or list[Attendee]</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">protocol</span><span class="o">=</span><span class="n">event</span><span class="o">.</span><span class="n">protocol</span><span class="p">,</span>
                         <span class="n">main_resource</span><span class="o">=</span><span class="n">event</span><span class="o">.</span><span class="n">main_resource</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_event</span> <span class="o">=</span> <span class="n">event</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__attendees</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">untrack</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="k">if</span> <span class="n">attendees</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">attendees</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">untrack</span> <span class="o">=</span> <span class="kc">False</span></div>

    <span class="k">def</span> <span class="fm">__iter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="nb">iter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__attendees</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__attendees</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>

    <span class="k">def</span> <span class="fm">__contains__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">item</span> <span class="ow">in</span> <span class="p">{</span><span class="n">attendee</span><span class="o">.</span><span class="n">email</span> <span class="k">for</span> <span class="n">attendee</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">__attendees</span><span class="p">}</span>

    <span class="k">def</span> <span class="fm">__len__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__attendees</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="fm">__repr__</span><span class="p">()</span>

    <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="s1">&#39;Attendees Count: </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__attendees</span><span class="p">))</span>

<div class="viewcode-block" id="Attendees.clear"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Attendees.clear">[docs]</a>    <span class="k">def</span> <span class="nf">clear</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Clear the attendees list &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__attendees</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="p">()</span></div>

    <span class="k">def</span> <span class="nf">_track_changes</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Update the track_changes on the event to reflect a needed</span>
<span class="sd">        update on this field &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">untrack</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_event</span><span class="o">.</span><span class="n">_track_changes</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s1">&#39;attendees&#39;</span><span class="p">)</span>

<div class="viewcode-block" id="Attendees.add"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Attendees.add">[docs]</a>    <span class="k">def</span> <span class="nf">add</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">attendees</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Add attendees to the parent event</span>

<span class="sd">        :param attendees: list of attendees to add</span>
<span class="sd">        :type attendees: str or tuple(str, str) or Attendee or list[str] or</span>
<span class="sd">         list[tuple(str,str)] or list[Attendee]</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">attendees</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">attendees</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">__attendees</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                    <span class="n">Attendee</span><span class="p">(</span><span class="n">address</span><span class="o">=</span><span class="n">attendees</span><span class="p">,</span> <span class="n">event</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_event</span><span class="p">))</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="p">()</span>
            <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">attendees</span><span class="p">,</span> <span class="n">Attendee</span><span class="p">):</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">__attendees</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">attendees</span><span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="p">()</span>
            <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">attendees</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">):</span>
                <span class="n">name</span><span class="p">,</span> <span class="n">address</span> <span class="o">=</span> <span class="n">attendees</span>
                <span class="k">if</span> <span class="n">address</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">__attendees</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                        <span class="n">Attendee</span><span class="p">(</span><span class="n">address</span><span class="o">=</span><span class="n">address</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">,</span> <span class="n">event</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_event</span><span class="p">))</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="p">()</span>
            <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">attendees</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
                <span class="k">for</span> <span class="n">attendee</span> <span class="ow">in</span> <span class="n">attendees</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">attendee</span><span class="p">)</span>
            <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">attendees</span><span class="p">,</span>
                            <span class="nb">dict</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cloud_data_key</span> <span class="ow">in</span> <span class="n">attendees</span><span class="p">:</span>
                <span class="n">attendees</span> <span class="o">=</span> <span class="n">attendees</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cloud_data_key</span><span class="p">)</span>
                <span class="k">for</span> <span class="n">attendee</span> <span class="ow">in</span> <span class="n">attendees</span><span class="p">:</span>
                    <span class="n">email</span> <span class="o">=</span> <span class="n">attendee</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;emailAddress&#39;</span><span class="p">),</span> <span class="p">{})</span>
                    <span class="n">address</span> <span class="o">=</span> <span class="n">email</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;address&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span>
                    <span class="k">if</span> <span class="n">address</span><span class="p">:</span>
                        <span class="n">name</span> <span class="o">=</span> <span class="n">email</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;name&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span>
                        <span class="c1"># default value</span>
                        <span class="n">attendee_type</span> <span class="o">=</span> <span class="n">attendee</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;type&#39;</span><span class="p">),</span>
                                                     <span class="s1">&#39;required&#39;</span><span class="p">)</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">__attendees</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                            <span class="n">Attendee</span><span class="p">(</span><span class="n">address</span><span class="o">=</span><span class="n">address</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">,</span>
                                     <span class="n">attendee_type</span><span class="o">=</span><span class="n">attendee_type</span><span class="p">,</span>
                                     <span class="n">event</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_event</span><span class="p">,</span>
                                     <span class="n">response_status</span><span class="o">=</span>
                                     <span class="n">ResponseStatus</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span>
                                                    <span class="n">response_status</span><span class="o">=</span>
                                                    <span class="n">attendee</span><span class="o">.</span><span class="n">get</span><span class="p">(</span>
                                                        <span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;status&#39;</span><span class="p">),</span>
                                                        <span class="p">{}))))</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;Attendees must be an address string, an &#39;</span>
                                 <span class="s1">&#39;Attendee instance, a (name, address) &#39;</span>
                                 <span class="s1">&#39;tuple or a list&#39;</span><span class="p">)</span></div>

<div class="viewcode-block" id="Attendees.remove"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Attendees.remove">[docs]</a>    <span class="k">def</span> <span class="nf">remove</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">attendees</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Remove the provided attendees from the event</span>

<span class="sd">        :param attendees: list of attendees to add</span>
<span class="sd">        :type attendees: str or tuple(str, str) or Attendee or list[str] or</span>
<span class="sd">         list[tuple(str,str)] or list[Attendee]</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">attendees</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">)):</span>
            <span class="n">attendees</span> <span class="o">=</span> <span class="p">{</span>
                <span class="n">attendee</span><span class="o">.</span><span class="n">address</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">attendee</span><span class="p">,</span> <span class="n">Attendee</span><span class="p">)</span> <span class="k">else</span> <span class="n">attendee</span>
                <span class="k">for</span>
                <span class="n">attendee</span> <span class="ow">in</span> <span class="n">attendees</span><span class="p">}</span>
        <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">attendees</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
            <span class="n">attendees</span> <span class="o">=</span> <span class="p">{</span><span class="n">attendees</span><span class="p">}</span>
        <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">attendees</span><span class="p">,</span> <span class="n">Attendee</span><span class="p">):</span>
            <span class="n">attendees</span> <span class="o">=</span> <span class="p">{</span><span class="n">attendees</span><span class="o">.</span><span class="n">address</span><span class="p">}</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;Incorrect parameter type for attendees&#39;</span><span class="p">)</span>

        <span class="n">new_attendees</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">attendee</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">__attendees</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">attendee</span><span class="o">.</span><span class="n">address</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">attendees</span><span class="p">:</span>
                <span class="n">new_attendees</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">attendee</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__attendees</span> <span class="o">=</span> <span class="n">new_attendees</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="p">()</span></div>

<div class="viewcode-block" id="Attendees.to_api_data"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Attendees.to_api_data">[docs]</a>    <span class="k">def</span> <span class="nf">to_api_data</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Returns a dict to communicate with the server</span>

<span class="sd">        :rtype: dict</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">data</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">attendee</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">__attendees</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">attendee</span><span class="o">.</span><span class="n">address</span><span class="p">:</span>
                <span class="n">att_data</span> <span class="o">=</span> <span class="p">{</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;emailAddress&#39;</span><span class="p">):</span> <span class="p">{</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;address&#39;</span><span class="p">):</span> <span class="n">attendee</span><span class="o">.</span><span class="n">address</span><span class="p">,</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;name&#39;</span><span class="p">):</span> <span class="n">attendee</span><span class="o">.</span><span class="n">name</span>
                    <span class="p">},</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;type&#39;</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="n">attendee</span><span class="o">.</span><span class="n">attendee_type</span><span class="o">.</span><span class="n">value</span><span class="p">)</span>
                <span class="p">}</span>
                <span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">att_data</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">data</span></div></div>


<span class="c1"># noinspection PyAttributeOutsideInit</span>
<div class="viewcode-block" id="Event"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Event">[docs]</a><span class="k">class</span> <span class="nc">Event</span><span class="p">(</span><span class="n">ApiComponent</span><span class="p">,</span> <span class="n">AttachableMixin</span><span class="p">,</span> <span class="n">HandleRecipientsMixin</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; A Calendar event &quot;&quot;&quot;</span>

    <span class="n">_endpoints</span> <span class="o">=</span> <span class="p">{</span>
        <span class="s1">&#39;calendar&#39;</span><span class="p">:</span> <span class="s1">&#39;/calendars/</span><span class="si">{id}</span><span class="s1">&#39;</span><span class="p">,</span>
        <span class="s1">&#39;event&#39;</span><span class="p">:</span> <span class="s1">&#39;/events/</span><span class="si">{id}</span><span class="s1">&#39;</span><span class="p">,</span>
        <span class="s1">&#39;event_default&#39;</span><span class="p">:</span> <span class="s1">&#39;/calendar/events&#39;</span><span class="p">,</span>
        <span class="s1">&#39;event_calendar&#39;</span><span class="p">:</span> <span class="s1">&#39;/calendars/</span><span class="si">{id}</span><span class="s1">/events&#39;</span><span class="p">,</span>
        <span class="s1">&#39;occurrences&#39;</span><span class="p">:</span> <span class="s1">&#39;/events/</span><span class="si">{id}</span><span class="s1">/instances&#39;</span><span class="p">,</span>
    <span class="p">}</span>

<div class="viewcode-block" id="Event.__init__"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Event.__init__">[docs]</a>    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">parent</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">con</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Create a calendar event representation</span>

<span class="sd">        :param parent: parent for this operation</span>
<span class="sd">        :type parent: Calendar or Schedule or ApiComponent</span>
<span class="sd">        :param Connection con: connection to use if no parent specified</span>
<span class="sd">        :param Protocol protocol: protocol to use if no parent specified</span>
<span class="sd">         (kwargs)</span>
<span class="sd">        :param str main_resource: use this resource instead of parent resource</span>
<span class="sd">         (kwargs)</span>
<span class="sd">        :param str calendar_id: id of the calender to add this event in</span>
<span class="sd">         (kwargs)</span>
<span class="sd">        :param bool download_attachments: whether or not to download attachments</span>
<span class="sd">         (kwargs)</span>
<span class="sd">        :param str subject: subject of the event (kwargs)</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">parent</span> <span class="ow">and</span> <span class="n">con</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;Need a parent or a connection but not both&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">con</span> <span class="o">=</span> <span class="n">parent</span><span class="o">.</span><span class="n">con</span> <span class="k">if</span> <span class="n">parent</span> <span class="k">else</span> <span class="n">con</span>

        <span class="c1"># Choose the main_resource passed in kwargs over parent main_resource</span>
        <span class="n">main_resource</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s1">&#39;main_resource&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span>
            <span class="nb">getattr</span><span class="p">(</span><span class="n">parent</span><span class="p">,</span> <span class="s1">&#39;main_resource&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">if</span> <span class="n">parent</span> <span class="k">else</span> <span class="kc">None</span><span class="p">)</span>

        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
            <span class="n">protocol</span><span class="o">=</span><span class="n">parent</span><span class="o">.</span><span class="n">protocol</span> <span class="k">if</span> <span class="n">parent</span> <span class="k">else</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;protocol&#39;</span><span class="p">),</span>
            <span class="n">main_resource</span><span class="o">=</span><span class="n">main_resource</span><span class="p">)</span>

        <span class="n">cc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cc</span>  <span class="c1"># alias</span>
        <span class="c1"># internal to know which properties need to be updated on the server</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span> <span class="o">=</span> <span class="n">TrackerSet</span><span class="p">(</span><span class="n">casing</span><span class="o">=</span><span class="n">cc</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">calendar_id</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;calendar_id&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
        <span class="n">download_attachments</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;download_attachments&#39;</span><span class="p">)</span>
        <span class="n">cloud_data</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cloud_data_key</span><span class="p">,</span> <span class="p">{})</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">object_id</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;id&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__subject</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;subject&#39;</span><span class="p">),</span>
                                        <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;subject&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)</span> <span class="ow">or</span> <span class="s1">&#39;&#39;</span><span class="p">)</span>
        <span class="n">body</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;body&#39;</span><span class="p">),</span> <span class="p">{})</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__body</span> <span class="o">=</span> <span class="n">body</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;content&#39;</span><span class="p">),</span> <span class="s1">&#39;&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">body_type</span> <span class="o">=</span> <span class="n">body</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;contentType&#39;</span><span class="p">),</span>
                                  <span class="s1">&#39;HTML&#39;</span><span class="p">)</span>  <span class="c1"># default to HTML for new messages</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">__attendees</span> <span class="o">=</span> <span class="n">Attendees</span><span class="p">(</span><span class="n">event</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> <span class="n">attendees</span><span class="o">=</span><span class="p">{</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_cloud_data_key</span><span class="p">:</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;attendees&#39;</span><span class="p">),</span> <span class="p">[])})</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__categories</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;categories&#39;</span><span class="p">),</span> <span class="p">[])</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">__created</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;createdDateTime&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__modified</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;lastModifiedDateTime&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span>

        <span class="n">local_tz</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">protocol</span><span class="o">.</span><span class="n">timezone</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__created</span> <span class="o">=</span> <span class="n">parse</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__created</span><span class="p">)</span><span class="o">.</span><span class="n">astimezone</span><span class="p">(</span>
            <span class="n">local_tz</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__created</span> <span class="k">else</span> <span class="kc">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__modified</span> <span class="o">=</span> <span class="n">parse</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__modified</span><span class="p">)</span><span class="o">.</span><span class="n">astimezone</span><span class="p">(</span>
            <span class="n">local_tz</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__modified</span> <span class="k">else</span> <span class="kc">None</span>

        <span class="n">start_obj</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;start&#39;</span><span class="p">),</span> <span class="p">{})</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_date_time_time_zone</span><span class="p">(</span><span class="n">start_obj</span><span class="p">)</span>

        <span class="n">end_obj</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;end&#39;</span><span class="p">),</span> <span class="p">{})</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_date_time_time_zone</span><span class="p">(</span><span class="n">end_obj</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">has_attachments</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;hasAttachments&#39;</span><span class="p">),</span> <span class="kc">False</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__attachments</span> <span class="o">=</span> <span class="n">EventAttachments</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> <span class="n">attachments</span><span class="o">=</span><span class="p">[])</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">has_attachments</span> <span class="ow">and</span> <span class="n">download_attachments</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">attachments</span><span class="o">.</span><span class="n">download_attachments</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__categories</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;categories&#39;</span><span class="p">),</span> <span class="p">[])</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">ical_uid</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;iCalUId&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__importance</span> <span class="o">=</span> <span class="n">ImportanceLevel</span><span class="o">.</span><span class="n">from_value</span><span class="p">(</span>
            <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;importance&#39;</span><span class="p">),</span> <span class="s1">&#39;normal&#39;</span><span class="p">)</span> <span class="ow">or</span> <span class="s1">&#39;normal&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__is_all_day</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;isAllDay&#39;</span><span class="p">),</span> <span class="kc">False</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">is_cancelled</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;isCancelled&#39;</span><span class="p">),</span> <span class="kc">False</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">is_organizer</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;isOrganizer&#39;</span><span class="p">),</span> <span class="kc">True</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__location</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;location&#39;</span><span class="p">),</span> <span class="p">{})</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">locations</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;locations&#39;</span><span class="p">),</span> <span class="p">[])</span>  <span class="c1"># TODO</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">online_meeting_url</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;onlineMeetingUrl&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__is_online_meeting</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;isOnlineMeeting&#39;</span><span class="p">),</span> <span class="kc">False</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__online_meeting_provider</span> <span class="o">=</span> <span class="n">OnlineMeetingProviderType</span><span class="o">.</span><span class="n">from_value</span><span class="p">(</span>
            <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;onlineMeetingProvider&#39;</span><span class="p">),</span> <span class="s1">&#39;teamsForBusiness&#39;</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">online_meeting</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;onlineMeeting&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">online_meeting_url</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_online_meeting</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">online_meeting_url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">online_meeting</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;joinUrl&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span> \
                <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">online_meeting</span> <span class="k">else</span> <span class="kc">None</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">__organizer</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_recipient_from_cloud</span><span class="p">(</span>
            <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;organizer&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">),</span> <span class="n">field</span><span class="o">=</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;organizer&#39;</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__recurrence</span> <span class="o">=</span> <span class="n">EventRecurrence</span><span class="p">(</span><span class="n">event</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span>
                                            <span class="n">recurrence</span><span class="o">=</span><span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span>
                                                <span class="n">cc</span><span class="p">(</span><span class="s1">&#39;recurrence&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__is_reminder_on</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;isReminderOn&#39;</span><span class="p">),</span> <span class="kc">True</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__remind_before_minutes</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span>
            <span class="n">cc</span><span class="p">(</span><span class="s1">&#39;reminderMinutesBeforeStart&#39;</span><span class="p">),</span> <span class="mi">15</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__response_requested</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;responseRequested&#39;</span><span class="p">),</span>
                                                   <span class="kc">True</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__response_status</span> <span class="o">=</span> <span class="n">ResponseStatus</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span>
                                                <span class="n">response_status</span><span class="o">=</span><span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span>
                                                    <span class="n">cc</span><span class="p">(</span><span class="s1">&#39;responseStatus&#39;</span><span class="p">),</span> <span class="p">{}))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__sensitivity</span> <span class="o">=</span> <span class="n">EventSensitivity</span><span class="o">.</span><span class="n">from_value</span><span class="p">(</span>
            <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;sensitivity&#39;</span><span class="p">),</span> <span class="s1">&#39;normal&#39;</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">series_master_id</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;seriesMasterId&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__show_as</span> <span class="o">=</span> <span class="n">EventShowAs</span><span class="o">.</span><span class="n">from_value</span><span class="p">(</span><span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;showAs&#39;</span><span class="p">),</span> <span class="s1">&#39;busy&#39;</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__event_type</span> <span class="o">=</span> <span class="n">EventType</span><span class="o">.</span><span class="n">from_value</span><span class="p">(</span><span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;type&#39;</span><span class="p">),</span> <span class="s1">&#39;singleInstance&#39;</span><span class="p">))</span></div>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="fm">__repr__</span><span class="p">()</span>

    <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">start</span><span class="o">.</span><span class="n">date</span><span class="p">()</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">end</span><span class="o">.</span><span class="n">date</span><span class="p">():</span>
            <span class="k">return</span> <span class="s1">&#39;Subject: </span><span class="si">{}</span><span class="s1"> (on: </span><span class="si">{}</span><span class="s1"> from: </span><span class="si">{}</span><span class="s1"> to: </span><span class="si">{}</span><span class="s1">)&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">subject</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">start</span><span class="o">.</span><span class="n">date</span><span class="p">(),</span> <span class="bp">self</span><span class="o">.</span><span class="n">start</span><span class="o">.</span><span class="n">time</span><span class="p">(),</span> <span class="bp">self</span><span class="o">.</span><span class="n">end</span><span class="o">.</span><span class="n">time</span><span class="p">())</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="s1">&#39;Subject: </span><span class="si">{}</span><span class="s1"> (starts: </span><span class="si">{}</span><span class="s1"> </span><span class="si">{}</span><span class="s1"> and ends: </span><span class="si">{}</span><span class="s1"> </span><span class="si">{}</span><span class="s1">)&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">subject</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">start</span><span class="o">.</span><span class="n">date</span><span class="p">(),</span> <span class="bp">self</span><span class="o">.</span><span class="n">start</span><span class="o">.</span><span class="n">time</span><span class="p">(),</span> <span class="bp">self</span><span class="o">.</span><span class="n">end</span><span class="o">.</span><span class="n">date</span><span class="p">(),</span>
                                                                        <span class="bp">self</span><span class="o">.</span><span class="n">end</span><span class="o">.</span><span class="n">time</span><span class="p">())</span>

    <span class="k">def</span> <span class="fm">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">object_id</span> <span class="o">==</span> <span class="n">other</span><span class="o">.</span><span class="n">object_id</span>

<div class="viewcode-block" id="Event.to_api_data"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Event.to_api_data">[docs]</a>    <span class="k">def</span> <span class="nf">to_api_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">restrict_keys</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Returns a dict to communicate with the server</span>

<span class="sd">        :param restrict_keys: a set of keys to restrict the returned data to</span>
<span class="sd">        :rtype: dict</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">cc</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cc</span>  <span class="c1"># alias</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__location</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__location</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
                <span class="n">location</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__location</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">location</span> <span class="o">=</span> <span class="p">{</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;displayName&#39;</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">__location</span><span class="p">}</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">location</span> <span class="o">=</span> <span class="p">{</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;displayName&#39;</span><span class="p">):</span> <span class="s1">&#39;&#39;</span><span class="p">}</span>

        <span class="n">data</span> <span class="o">=</span> <span class="p">{</span>
            <span class="n">cc</span><span class="p">(</span><span class="s1">&#39;subject&#39;</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">__subject</span><span class="p">,</span>
            <span class="n">cc</span><span class="p">(</span><span class="s1">&#39;body&#39;</span><span class="p">):</span> <span class="p">{</span>
                <span class="n">cc</span><span class="p">(</span><span class="s1">&#39;contentType&#39;</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">body_type</span><span class="p">,</span>
                <span class="n">cc</span><span class="p">(</span><span class="s1">&#39;content&#39;</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">__body</span><span class="p">},</span>
            <span class="n">cc</span><span class="p">(</span><span class="s1">&#39;start&#39;</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">_build_date_time_time_zone</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__start</span><span class="p">),</span>
            <span class="n">cc</span><span class="p">(</span><span class="s1">&#39;end&#39;</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">_build_date_time_time_zone</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__end</span><span class="p">),</span>
            <span class="n">cc</span><span class="p">(</span><span class="s1">&#39;attendees&#39;</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">__attendees</span><span class="o">.</span><span class="n">to_api_data</span><span class="p">(),</span>
            <span class="n">cc</span><span class="p">(</span><span class="s1">&#39;location&#39;</span><span class="p">):</span> <span class="n">location</span><span class="p">,</span>
            <span class="n">cc</span><span class="p">(</span><span class="s1">&#39;categories&#39;</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">__categories</span><span class="p">,</span>
            <span class="n">cc</span><span class="p">(</span><span class="s1">&#39;isAllDay&#39;</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">__is_all_day</span><span class="p">,</span>
            <span class="n">cc</span><span class="p">(</span><span class="s1">&#39;importance&#39;</span><span class="p">):</span> <span class="n">cc</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__importance</span><span class="o">.</span><span class="n">value</span><span class="p">),</span>
            <span class="n">cc</span><span class="p">(</span><span class="s1">&#39;isReminderOn&#39;</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">__is_reminder_on</span><span class="p">,</span>
            <span class="n">cc</span><span class="p">(</span><span class="s1">&#39;reminderMinutesBeforeStart&#39;</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">__remind_before_minutes</span><span class="p">,</span>
            <span class="n">cc</span><span class="p">(</span><span class="s1">&#39;responseRequested&#39;</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">__response_requested</span><span class="p">,</span>
            <span class="n">cc</span><span class="p">(</span><span class="s1">&#39;sensitivity&#39;</span><span class="p">):</span> <span class="n">cc</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__sensitivity</span><span class="o">.</span><span class="n">value</span><span class="p">),</span>
            <span class="n">cc</span><span class="p">(</span><span class="s1">&#39;showAs&#39;</span><span class="p">):</span> <span class="n">cc</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__show_as</span><span class="o">.</span><span class="n">value</span><span class="p">),</span>
            <span class="n">cc</span><span class="p">(</span><span class="s1">&#39;isOnlineMeeting&#39;</span><span class="p">):</span> <span class="n">cc</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__is_online_meeting</span><span class="p">),</span>
            <span class="n">cc</span><span class="p">(</span><span class="s1">&#39;onlineMeetingProvider&#39;</span><span class="p">):</span> <span class="n">cc</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__online_meeting_provider</span><span class="o">.</span><span class="n">value</span><span class="p">),</span>
        <span class="p">}</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__recurrence</span><span class="p">:</span>
            <span class="n">data</span><span class="p">[</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;recurrence&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__recurrence</span><span class="o">.</span><span class="n">to_api_data</span><span class="p">()</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">has_attachments</span><span class="p">:</span>
            <span class="n">data</span><span class="p">[</span><span class="n">cc</span><span class="p">(</span><span class="s1">&#39;attachments&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__attachments</span><span class="o">.</span><span class="n">to_api_data</span><span class="p">()</span>

        <span class="k">if</span> <span class="n">restrict_keys</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">keys</span><span class="p">()):</span>
                <span class="k">if</span> <span class="n">key</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">restrict_keys</span><span class="p">:</span>
                    <span class="k">del</span> <span class="n">data</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
        <span class="k">return</span> <span class="n">data</span></div>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">created</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Created time of the event</span>

<span class="sd">        :rtype: datetime</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__created</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">modified</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Last modified time of the event</span>

<span class="sd">        :rtype: datetime</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__modified</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">body</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Body of the event</span>

<span class="sd">        :getter: Get body text</span>
<span class="sd">        :setter: Set body of event</span>
<span class="sd">        :type: str</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__body</span>

    <span class="nd">@body</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">body</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__body</span> <span class="o">=</span> <span class="n">value</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;body&#39;</span><span class="p">))</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">subject</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Subject of the event</span>

<span class="sd">        :getter: Get subject</span>
<span class="sd">        :setter: Set subject of event</span>
<span class="sd">        :type: str</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__subject</span>

    <span class="nd">@subject</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">subject</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__subject</span> <span class="o">=</span> <span class="n">value</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;subject&#39;</span><span class="p">))</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">start</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Start Time of event</span>

<span class="sd">        :getter: get the start time</span>
<span class="sd">        :setter: set the start time</span>
<span class="sd">        :type: datetime</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__start</span>

    <span class="nd">@start</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">start</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">dt</span><span class="o">.</span><span class="n">date</span><span class="p">):</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;&#39;start&#39; must be a valid datetime object&quot;</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">dt</span><span class="o">.</span><span class="n">datetime</span><span class="p">):</span>
            <span class="c1"># force datetime</span>
            <span class="n">value</span> <span class="o">=</span> <span class="n">dt</span><span class="o">.</span><span class="n">datetime</span><span class="p">(</span><span class="n">value</span><span class="o">.</span><span class="n">year</span><span class="p">,</span> <span class="n">value</span><span class="o">.</span><span class="n">month</span><span class="p">,</span> <span class="n">value</span><span class="o">.</span><span class="n">day</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">value</span><span class="o">.</span><span class="n">tzinfo</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="c1"># localize datetime</span>
            <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">protocol</span><span class="o">.</span><span class="n">timezone</span><span class="o">.</span><span class="n">localize</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">value</span><span class="o">.</span><span class="n">tzinfo</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">protocol</span><span class="o">.</span><span class="n">timezone</span><span class="p">:</span>
            <span class="n">value</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">astimezone</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">protocol</span><span class="o">.</span><span class="n">timezone</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__start</span> <span class="o">=</span> <span class="n">value</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">end</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__start</span> <span class="o">+</span> <span class="n">dt</span><span class="o">.</span><span class="n">timedelta</span><span class="p">(</span><span class="n">minutes</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;start&#39;</span><span class="p">))</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">end</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; End Time of event</span>

<span class="sd">        :getter: get the end time</span>
<span class="sd">        :setter: set the end time</span>
<span class="sd">        :type: datetime</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__end</span>

    <span class="nd">@end</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">end</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">dt</span><span class="o">.</span><span class="n">date</span><span class="p">):</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;&#39;end&#39; must be a valid datetime object&quot;</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">dt</span><span class="o">.</span><span class="n">datetime</span><span class="p">):</span>
            <span class="c1"># force datetime</span>
            <span class="n">value</span> <span class="o">=</span> <span class="n">dt</span><span class="o">.</span><span class="n">datetime</span><span class="p">(</span><span class="n">value</span><span class="o">.</span><span class="n">year</span><span class="p">,</span> <span class="n">value</span><span class="o">.</span><span class="n">month</span><span class="p">,</span> <span class="n">value</span><span class="o">.</span><span class="n">day</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">value</span><span class="o">.</span><span class="n">tzinfo</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="c1"># localize datetime</span>
            <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">protocol</span><span class="o">.</span><span class="n">timezone</span><span class="o">.</span><span class="n">localize</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">value</span><span class="o">.</span><span class="n">tzinfo</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">protocol</span><span class="o">.</span><span class="n">timezone</span><span class="p">:</span>
            <span class="n">value</span> <span class="o">=</span> <span class="n">value</span><span class="o">.</span><span class="n">astimezone</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">protocol</span><span class="o">.</span><span class="n">timezone</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__end</span> <span class="o">=</span> <span class="n">value</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;end&#39;</span><span class="p">))</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">importance</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Event Priority</span>

<span class="sd">        :getter: get importance of event</span>
<span class="sd">        :setter: set the importance of event</span>
<span class="sd">        :type: ImportanceLevel</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__importance</span>

    <span class="nd">@importance</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">importance</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__importance</span> <span class="o">=</span> <span class="p">(</span><span class="n">value</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">ImportanceLevel</span><span class="p">)</span>
                             <span class="k">else</span> <span class="n">ImportanceLevel</span><span class="o">.</span><span class="n">from_value</span><span class="p">(</span><span class="n">value</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;importance&#39;</span><span class="p">))</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">is_all_day</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Is the event for whole day</span>

<span class="sd">        :getter: get the current status of is_all_day property</span>
<span class="sd">        :setter: set if the event is all day or not</span>
<span class="sd">        :type: bool</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__is_all_day</span>

    <span class="nd">@is_all_day</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">is_all_day</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__is_all_day</span> <span class="o">=</span> <span class="n">value</span>
        <span class="k">if</span> <span class="n">value</span><span class="p">:</span>
            <span class="c1"># Api requirement: start and end must be set to midnight</span>
            <span class="c1"># is_all_day needs event.start included in the request on updates</span>
            <span class="c1"># is_all_day needs event.end included in the request on updates</span>
            <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__start</span> <span class="ow">or</span> <span class="n">dt</span><span class="o">.</span><span class="n">date</span><span class="o">.</span><span class="n">today</span><span class="p">()</span>
            <span class="n">end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__end</span> <span class="ow">or</span> <span class="n">dt</span><span class="o">.</span><span class="n">date</span><span class="o">.</span><span class="n">today</span><span class="p">()</span>

            <span class="k">if</span> <span class="p">(</span><span class="n">start</span> <span class="o">+</span> <span class="n">dt</span><span class="o">.</span><span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="mi">24</span><span class="p">))</span> <span class="o">&gt;</span> <span class="n">end</span><span class="p">:</span>
                <span class="c1"># Api requires that under is_all_day=True start and</span>
                <span class="c1"># end must be at least 24 hours away</span>
                <span class="n">end</span> <span class="o">=</span> <span class="n">start</span> <span class="o">+</span> <span class="n">dt</span><span class="o">.</span><span class="n">timedelta</span><span class="p">(</span><span class="n">hours</span><span class="o">=</span><span class="mi">24</span><span class="p">)</span>

            <span class="c1"># set to midnight</span>
            <span class="n">start</span> <span class="o">=</span> <span class="n">dt</span><span class="o">.</span><span class="n">datetime</span><span class="p">(</span><span class="n">start</span><span class="o">.</span><span class="n">year</span><span class="p">,</span> <span class="n">start</span><span class="o">.</span><span class="n">month</span><span class="p">,</span> <span class="n">start</span><span class="o">.</span><span class="n">day</span><span class="p">)</span>
            <span class="n">end</span> <span class="o">=</span> <span class="n">dt</span><span class="o">.</span><span class="n">datetime</span><span class="p">(</span><span class="n">end</span><span class="o">.</span><span class="n">year</span><span class="p">,</span> <span class="n">end</span><span class="o">.</span><span class="n">month</span><span class="p">,</span> <span class="n">end</span><span class="o">.</span><span class="n">day</span><span class="p">)</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">start</span> <span class="o">=</span> <span class="n">start</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">end</span> <span class="o">=</span> <span class="n">end</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;isAllDay&#39;</span><span class="p">))</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">location</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Location of event</span>

<span class="sd">        :getter: get current location configured for the event</span>
<span class="sd">        :setter: set a location for the event</span>
<span class="sd">        :type: str</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__location</span>

    <span class="nd">@location</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">location</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__location</span> <span class="o">=</span> <span class="n">value</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;location&#39;</span><span class="p">))</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">is_reminder_on</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Status of the Reminder</span>

<span class="sd">        :getter: check is reminder enabled or not</span>
<span class="sd">        :setter: enable or disable reminder option</span>
<span class="sd">        :type: bool</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__is_reminder_on</span>

    <span class="nd">@is_reminder_on</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">is_reminder_on</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__is_reminder_on</span> <span class="o">=</span> <span class="n">value</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;isReminderOn&#39;</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;reminderMinutesBeforeStart&#39;</span><span class="p">))</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">remind_before_minutes</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; No. of minutes to remind before the meeting</span>

<span class="sd">        :getter: get current minutes</span>
<span class="sd">        :setter: set to remind before new x minutes</span>
<span class="sd">        :type: int</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__remind_before_minutes</span>

    <span class="nd">@remind_before_minutes</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">remind_before_minutes</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__is_reminder_on</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__remind_before_minutes</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;isReminderOn&#39;</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;reminderMinutesBeforeStart&#39;</span><span class="p">))</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">response_requested</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Is response requested or not</span>

<span class="sd">        :getter: Is response requested or not</span>
<span class="sd">        :setter: set the event to request response or not</span>
<span class="sd">        :type: bool</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__response_requested</span>

    <span class="nd">@response_requested</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">response_requested</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__response_requested</span> <span class="o">=</span> <span class="n">value</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;responseRequested&#39;</span><span class="p">))</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">recurrence</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Recurrence information of the event</span>

<span class="sd">        :rtype: EventRecurrence</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__recurrence</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">organizer</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Organizer of the meeting event</span>

<span class="sd">        :rtype: Recipient</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__organizer</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">show_as</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Show as &quot;busy&quot; or any other status during the event</span>

<span class="sd">        :getter: Current status during the event</span>
<span class="sd">        :setter: update show as status</span>
<span class="sd">        :type: EventShowAs</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__show_as</span>

    <span class="nd">@show_as</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">show_as</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__show_as</span> <span class="o">=</span> <span class="p">(</span><span class="n">value</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">EventShowAs</span><span class="p">)</span>
                          <span class="k">else</span> <span class="n">EventShowAs</span><span class="o">.</span><span class="n">from_value</span><span class="p">(</span><span class="n">value</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;showAs&#39;</span><span class="p">))</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">sensitivity</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Sensitivity of the Event</span>

<span class="sd">        :getter: Get the current sensitivity</span>
<span class="sd">        :setter: Set a new sensitivity</span>
<span class="sd">        :type: EventSensitivity</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__sensitivity</span>

    <span class="nd">@sensitivity</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">sensitivity</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__sensitivity</span> <span class="o">=</span> <span class="p">(</span><span class="n">value</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">EventSensitivity</span><span class="p">)</span>
                              <span class="k">else</span> <span class="n">EventSensitivity</span><span class="o">.</span><span class="n">from_value</span><span class="p">(</span><span class="n">value</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;sensitivity&#39;</span><span class="p">))</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">response_status</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Your response</span>

<span class="sd">        :rtype: ResponseStatus</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__response_status</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">attachments</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; List of attachments</span>

<span class="sd">        :rtype: EventAttachments</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__attachments</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">attendees</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; List of meeting attendees</span>

<span class="sd">        :rtype: Attendees</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__attendees</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">categories</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Categories of the event</span>

<span class="sd">        :getter: get the list of categories</span>
<span class="sd">        :setter: set the list of categories</span>
<span class="sd">        :type: list[str]</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__categories</span>

    <span class="nd">@categories</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">categories</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">__categories</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">for</span> <span class="n">val</span> <span class="ow">in</span> <span class="n">value</span><span class="p">:</span>
                <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">val</span><span class="p">,</span> <span class="n">Category</span><span class="p">):</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">__categories</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">val</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">__categories</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">val</span><span class="p">)</span>
        <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">__categories</span> <span class="o">=</span> <span class="p">[</span><span class="n">value</span><span class="p">]</span>
        <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">Category</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">__categories</span> <span class="o">=</span> <span class="p">[</span><span class="n">value</span><span class="o">.</span><span class="n">name</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;categories must be a list&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;categories&#39;</span><span class="p">))</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">event_type</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__event_type</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">is_online_meeting</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Status of the online_meeting</span>

<span class="sd">        :getter: check is online_meeting enabled or not</span>
<span class="sd">        :setter: enable or disable online_meeting option</span>
<span class="sd">        :type: bool</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__is_online_meeting</span>

    <span class="nd">@is_online_meeting</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">is_online_meeting</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__is_online_meeting</span> <span class="o">=</span> <span class="n">value</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;isOnlineMeeting&#39;</span><span class="p">))</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">online_meeting_provider</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; online_meeting_provider of event</span>

<span class="sd">        :getter: get current online_meeting_provider configured for the event</span>
<span class="sd">        :setter: set a online_meeting_provider for the event</span>
<span class="sd">        :type: OnlineMeetingProviderType</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__online_meeting_provider</span>

    <span class="nd">@online_meeting_provider</span><span class="o">.</span><span class="n">setter</span>
    <span class="k">def</span> <span class="nf">online_meeting_provider</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__online_meeting_provider</span> <span class="o">=</span> <span class="p">(</span><span class="n">value</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">OnlineMeetingProviderType</span><span class="p">)</span>
                             <span class="k">else</span> <span class="n">OnlineMeetingProviderType</span><span class="o">.</span><span class="n">from_value</span><span class="p">(</span><span class="n">value</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;onlineMeetingProvider&#39;</span><span class="p">))</span>

<div class="viewcode-block" id="Event.get_occurrences"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Event.get_occurrences">[docs]</a>    <span class="k">def</span> <span class="nf">get_occurrences</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">limit</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">query</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">order_by</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">batch</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns all the occurrences of a seriesMaster event for a specified time range.</span>
<span class="sd">        :type start: datetime</span>
<span class="sd">        :param start: the start of the time range</span>
<span class="sd">        :type end: datetime</span>
<span class="sd">        :param end: the end of the time range</span>
<span class="sd">        :param int limit: ax no. of events to get. Over 999 uses batch.</span>
<span class="sd">        :type query: Query or str</span>
<span class="sd">        :param query: optional. extra filters or ordes to apply to this query</span>
<span class="sd">        :type order_by: str</span>
<span class="sd">        :param order_by: orders the result set based on this condition</span>
<span class="sd">        :param int batch: batch size, retrieves items in</span>
<span class="sd">             batches allowing to retrieve more items than the limit.</span>
<span class="sd">        :return: a list of events</span>
<span class="sd">        :rtype: list[Event] or Pagination</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">event_type</span> <span class="o">!=</span> <span class="n">EventType</span><span class="o">.</span><span class="n">SeriesMaster</span><span class="p">:</span>
            <span class="c1"># you can only get occurrences if its a seriesMaster</span>
            <span class="k">return</span> <span class="p">[]</span>

        <span class="n">url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_url</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_endpoints</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;occurrences&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">object_id</span><span class="p">))</span>

        <span class="k">if</span> <span class="n">limit</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="n">limit</span> <span class="o">&gt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">protocol</span><span class="o">.</span><span class="n">max_top_value</span><span class="p">:</span>
            <span class="n">batch</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">protocol</span><span class="o">.</span><span class="n">max_top_value</span>

        <span class="n">params</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;$top&#39;</span><span class="p">:</span> <span class="n">batch</span> <span class="k">if</span> <span class="n">batch</span> <span class="k">else</span> <span class="n">limit</span><span class="p">}</span>

        <span class="k">if</span> <span class="n">order_by</span><span class="p">:</span>
            <span class="n">params</span><span class="p">[</span><span class="s1">&#39;$orderby&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">order_by</span>

        <span class="k">if</span> <span class="n">query</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">query</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
                <span class="n">params</span><span class="p">[</span><span class="s1">&#39;$filter&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">query</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">params</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">query</span><span class="o">.</span><span class="n">as_params</span><span class="p">())</span>

        <span class="k">if</span> <span class="n">start</span><span class="o">.</span><span class="n">tzinfo</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="c1"># if it&#39;s a naive datetime, localize the datetime.</span>
            <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">protocol</span><span class="o">.</span><span class="n">timezone</span><span class="o">.</span><span class="n">localize</span><span class="p">(</span><span class="n">start</span><span class="p">)</span>  <span class="c1"># localize datetime into local tz</span>
        <span class="k">if</span> <span class="n">start</span><span class="o">.</span><span class="n">tzinfo</span> <span class="o">!=</span> <span class="n">pytz</span><span class="o">.</span><span class="n">utc</span><span class="p">:</span>
            <span class="n">start</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">astimezone</span><span class="p">(</span><span class="n">pytz</span><span class="o">.</span><span class="n">utc</span><span class="p">)</span>  <span class="c1"># transform local datetime to utc</span>

        <span class="k">if</span> <span class="n">end</span><span class="o">.</span><span class="n">tzinfo</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="c1"># if it&#39;s a naive datetime, localize the datetime.</span>
            <span class="n">end</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">protocol</span><span class="o">.</span><span class="n">timezone</span><span class="o">.</span><span class="n">localize</span><span class="p">(</span><span class="n">end</span><span class="p">)</span>  <span class="c1"># localize datetime into local tz</span>
        <span class="k">if</span> <span class="n">end</span><span class="o">.</span><span class="n">tzinfo</span> <span class="o">!=</span> <span class="n">pytz</span><span class="o">.</span><span class="n">utc</span><span class="p">:</span>
            <span class="n">end</span> <span class="o">=</span> <span class="n">end</span><span class="o">.</span><span class="n">astimezone</span><span class="p">(</span><span class="n">pytz</span><span class="o">.</span><span class="n">utc</span><span class="p">)</span>  <span class="c1"># transform local datetime to utc</span>

        <span class="n">params</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;startDateTime&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="n">start</span><span class="o">.</span><span class="n">isoformat</span><span class="p">()</span>
        <span class="n">params</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;endDateTime&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="n">end</span><span class="o">.</span><span class="n">isoformat</span><span class="p">()</span>

        <span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">con</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">params</span><span class="o">=</span><span class="n">params</span><span class="p">,</span>
                                <span class="n">headers</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;Prefer&#39;</span><span class="p">:</span> <span class="s1">&#39;outlook.timezone=&quot;UTC&quot;&#39;</span><span class="p">})</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">response</span><span class="p">:</span>
            <span class="k">return</span> <span class="nb">iter</span><span class="p">(())</span>

        <span class="n">data</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">json</span><span class="p">()</span>

        <span class="c1"># Everything received from cloud must be passed as self._cloud_data_key</span>
        <span class="n">events</span> <span class="o">=</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="p">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_cloud_data_key</span><span class="p">:</span> <span class="n">event</span><span class="p">})</span>
                  <span class="k">for</span> <span class="n">event</span> <span class="ow">in</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;value&#39;</span><span class="p">,</span> <span class="p">[]))</span>
        <span class="n">next_link</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">NEXT_LINK_KEYWORD</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">batch</span> <span class="ow">and</span> <span class="n">next_link</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">Pagination</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">events</span><span class="p">,</span>
                              <span class="n">constructor</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="p">,</span>
                              <span class="n">next_link</span><span class="o">=</span><span class="n">next_link</span><span class="p">,</span> <span class="n">limit</span><span class="o">=</span><span class="n">limit</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">events</span></div>

<div class="viewcode-block" id="Event.delete"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Event.delete">[docs]</a>    <span class="k">def</span> <span class="nf">delete</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Deletes a stored event</span>

<span class="sd">        :return: Success / Failure</span>
<span class="sd">        :rtype: bool</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">object_id</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s1">&#39;Attempting to delete an unsaved event&#39;</span><span class="p">)</span>

        <span class="n">url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_url</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_endpoints</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;event&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">object_id</span><span class="p">))</span>

        <span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">con</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="n">url</span><span class="p">)</span>

        <span class="k">return</span> <span class="nb">bool</span><span class="p">(</span><span class="n">response</span><span class="p">)</span></div>

<div class="viewcode-block" id="Event.save"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Event.save">[docs]</a>    <span class="k">def</span> <span class="nf">save</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Create a new event or update an existing one by checking what</span>
<span class="sd">        values have changed and update them on the server</span>

<span class="sd">        :return: Success / Failure</span>
<span class="sd">        :rtype: bool</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">object_id</span><span class="p">:</span>
            <span class="c1"># update event</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="p">:</span>
                <span class="k">return</span> <span class="kc">True</span>  <span class="c1"># there&#39;s nothing to update</span>
            <span class="n">url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_url</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_endpoints</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;event&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">object_id</span><span class="p">))</span>
            <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">con</span><span class="o">.</span><span class="n">patch</span>
            <span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">to_api_data</span><span class="p">(</span><span class="n">restrict_keys</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="c1"># new event</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">calendar_id</span><span class="p">:</span>
                <span class="n">url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_url</span><span class="p">(</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">_endpoints</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;event_calendar&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="nb">id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">calendar_id</span><span class="p">))</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_url</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_endpoints</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;event_default&#39;</span><span class="p">))</span>
            <span class="n">method</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">con</span><span class="o">.</span><span class="n">post</span>
            <span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">to_api_data</span><span class="p">()</span>

        <span class="n">response</span> <span class="o">=</span> <span class="n">method</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">response</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">False</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_track_changes</span><span class="o">.</span><span class="n">clear</span><span class="p">()</span>  <span class="c1"># clear the tracked changes</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">object_id</span><span class="p">:</span>
            <span class="c1"># new event</span>
            <span class="n">event</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">json</span><span class="p">()</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">object_id</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;id&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">__created</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;createdDateTime&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">__modified</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;lastModifiedDateTime&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span>

            <span class="bp">self</span><span class="o">.</span><span class="n">__created</span> <span class="o">=</span> <span class="n">parse</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__created</span><span class="p">)</span><span class="o">.</span><span class="n">astimezone</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">protocol</span><span class="o">.</span><span class="n">timezone</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__created</span> <span class="k">else</span> <span class="kc">None</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">__modified</span> <span class="o">=</span> <span class="n">parse</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__modified</span><span class="p">)</span><span class="o">.</span><span class="n">astimezone</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">protocol</span><span class="o">.</span><span class="n">timezone</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">__modified</span> <span class="k">else</span> <span class="kc">None</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">__modified</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">protocol</span><span class="o">.</span><span class="n">timezone</span><span class="o">.</span><span class="n">localize</span><span class="p">(</span><span class="n">dt</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">())</span>

        <span class="k">return</span> <span class="kc">True</span></div>

<div class="viewcode-block" id="Event.accept_event"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Event.accept_event">[docs]</a>    <span class="k">def</span> <span class="nf">accept_event</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">send_response</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                     <span class="n">tentatively</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Accept the event</span>

<span class="sd">        :param comment: comment to add</span>
<span class="sd">        :param send_response: whether or not to send response back</span>
<span class="sd">        :param tentatively: whether acceptance is tentative</span>
<span class="sd">        :return: Success / Failure</span>
<span class="sd">        :rtype: bool</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">object_id</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">&quot;Can&#39;t accept event that doesn&#39;t exist&quot;</span><span class="p">)</span>

        <span class="n">url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_url</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_endpoints</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;event&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">object_id</span><span class="p">))</span>
        <span class="n">url</span> <span class="o">=</span> <span class="n">url</span> <span class="o">+</span> <span class="s1">&#39;/tentativelyAccept&#39;</span> <span class="k">if</span> <span class="n">tentatively</span> <span class="k">else</span> <span class="n">url</span> <span class="o">+</span> <span class="s1">&#39;/accept&#39;</span>

        <span class="n">data</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">if</span> <span class="n">comment</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">comment</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
            <span class="n">data</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;comment&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="n">comment</span>
        <span class="k">if</span> <span class="n">send_response</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span>
            <span class="n">data</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;sendResponse&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="n">send_response</span>

        <span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">con</span><span class="o">.</span><span class="n">post</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">data</span> <span class="ow">or</span> <span class="kc">None</span><span class="p">)</span>

        <span class="k">return</span> <span class="nb">bool</span><span class="p">(</span><span class="n">response</span><span class="p">)</span></div>

<div class="viewcode-block" id="Event.decline_event"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Event.decline_event">[docs]</a>    <span class="k">def</span> <span class="nf">decline_event</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">send_response</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Decline the event</span>

<span class="sd">        :param str comment: comment to add</span>
<span class="sd">        :param bool send_response: whether or not to send response back</span>
<span class="sd">        :return: Success / Failure</span>
<span class="sd">        :rtype: bool</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">object_id</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s2">&quot;Can&#39;t accept event that doesn&#39;t exist&quot;</span><span class="p">)</span>

        <span class="n">url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_url</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_endpoints</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;event&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">object_id</span><span class="p">))</span>
        <span class="n">url</span> <span class="o">=</span> <span class="n">url</span> <span class="o">+</span> <span class="s1">&#39;/decline&#39;</span>

        <span class="n">data</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">if</span> <span class="n">comment</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">comment</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
            <span class="n">data</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;comment&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="n">comment</span>
        <span class="k">if</span> <span class="n">send_response</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span>
            <span class="n">data</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;sendResponse&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="n">send_response</span>

        <span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">con</span><span class="o">.</span><span class="n">post</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">data</span> <span class="ow">or</span> <span class="kc">None</span><span class="p">)</span>

        <span class="k">return</span> <span class="nb">bool</span><span class="p">(</span><span class="n">response</span><span class="p">)</span></div>

<div class="viewcode-block" id="Event.get_body_text"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Event.get_body_text">[docs]</a>    <span class="k">def</span> <span class="nf">get_body_text</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Parse the body html and returns the body text using bs4</span>

<span class="sd">        :return: body text</span>
<span class="sd">        :rtype: str</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">body_type</span> <span class="o">!=</span> <span class="s1">&#39;HTML&#39;</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">body</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="n">soup</span> <span class="o">=</span> <span class="n">bs</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">body</span><span class="p">,</span> <span class="s1">&#39;html.parser&#39;</span><span class="p">)</span>
        <span class="k">except</span> <span class="ne">RuntimeError</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">body</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">soup</span><span class="o">.</span><span class="n">body</span><span class="o">.</span><span class="n">text</span></div>

<div class="viewcode-block" id="Event.get_body_soup"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Event.get_body_soup">[docs]</a>    <span class="k">def</span> <span class="nf">get_body_soup</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Returns the beautifulsoup4 of the html body</span>

<span class="sd">        :return: Html body</span>
<span class="sd">        :rtype: BeautifulSoup</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">body_type</span> <span class="o">!=</span> <span class="s1">&#39;HTML&#39;</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">None</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">bs</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">body</span><span class="p">,</span> <span class="s1">&#39;html.parser&#39;</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="Calendar"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Calendar">[docs]</a><span class="k">class</span> <span class="nc">Calendar</span><span class="p">(</span><span class="n">ApiComponent</span><span class="p">,</span> <span class="n">HandleRecipientsMixin</span><span class="p">):</span>
    <span class="n">_endpoints</span> <span class="o">=</span> <span class="p">{</span>
        <span class="s1">&#39;calendar&#39;</span><span class="p">:</span> <span class="s1">&#39;/calendars/</span><span class="si">{id}</span><span class="s1">&#39;</span><span class="p">,</span>
        <span class="s1">&#39;get_events&#39;</span><span class="p">:</span> <span class="s1">&#39;/calendars/</span><span class="si">{id}</span><span class="s1">/events&#39;</span><span class="p">,</span>
        <span class="s1">&#39;default_events&#39;</span><span class="p">:</span> <span class="s1">&#39;/calendar/events&#39;</span><span class="p">,</span>
        <span class="s1">&#39;events_view&#39;</span><span class="p">:</span> <span class="s1">&#39;/calendars/</span><span class="si">{id}</span><span class="s1">/calendarView&#39;</span><span class="p">,</span>
        <span class="s1">&#39;default_events_view&#39;</span><span class="p">:</span> <span class="s1">&#39;/calendar/calendarView&#39;</span><span class="p">,</span>
        <span class="s1">&#39;get_event&#39;</span><span class="p">:</span> <span class="s1">&#39;/calendars/</span><span class="si">{id}</span><span class="s1">/events/</span><span class="si">{ide}</span><span class="s1">&#39;</span><span class="p">,</span>
    <span class="p">}</span>
    <span class="n">event_constructor</span> <span class="o">=</span> <span class="n">Event</span>

<div class="viewcode-block" id="Calendar.__init__"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Calendar.__init__">[docs]</a>    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">parent</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">con</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Create a Calendar Representation</span>

<span class="sd">        :param parent: parent for this operation</span>
<span class="sd">        :type parent: Schedule</span>
<span class="sd">        :param Connection con: connection to use if no parent specified</span>
<span class="sd">        :param Protocol protocol: protocol to use if no parent specified</span>
<span class="sd">         (kwargs)</span>
<span class="sd">        :param str main_resource: use this resource instead of parent resource</span>
<span class="sd">         (kwargs)</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">parent</span> <span class="ow">and</span> <span class="n">con</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;Need a parent or a connection but not both&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">con</span> <span class="o">=</span> <span class="n">parent</span><span class="o">.</span><span class="n">con</span> <span class="k">if</span> <span class="n">parent</span> <span class="k">else</span> <span class="n">con</span>

        <span class="c1"># Choose the main_resource passed in kwargs over parent main_resource</span>
        <span class="n">main_resource</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s1">&#39;main_resource&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span>
            <span class="nb">getattr</span><span class="p">(</span><span class="n">parent</span><span class="p">,</span> <span class="s1">&#39;main_resource&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">if</span> <span class="n">parent</span> <span class="k">else</span> <span class="kc">None</span><span class="p">)</span>

        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
            <span class="n">protocol</span><span class="o">=</span><span class="n">parent</span><span class="o">.</span><span class="n">protocol</span> <span class="k">if</span> <span class="n">parent</span> <span class="k">else</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;protocol&#39;</span><span class="p">),</span>
            <span class="n">main_resource</span><span class="o">=</span><span class="n">main_resource</span><span class="p">)</span>

        <span class="n">cloud_data</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cloud_data_key</span><span class="p">,</span> <span class="p">{})</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;name&#39;</span><span class="p">),</span> <span class="s1">&#39;&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">calendar_id</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;id&#39;</span><span class="p">),</span> <span class="kc">None</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__owner</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_recipient_from_cloud</span><span class="p">(</span>
            <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;owner&#39;</span><span class="p">),</span> <span class="p">{}),</span> <span class="n">field</span><span class="o">=</span><span class="s1">&#39;owner&#39;</span><span class="p">)</span>
        <span class="n">color</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;color&#39;</span><span class="p">),</span> <span class="s1">&#39;auto&#39;</span><span class="p">)</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">color</span> <span class="o">=</span> <span class="n">CalendarColor</span><span class="o">.</span><span class="n">from_value</span><span class="p">(</span><span class="n">color</span><span class="p">)</span>
        <span class="k">except</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">color</span> <span class="o">=</span> <span class="n">CalendarColor</span><span class="o">.</span><span class="n">from_value</span><span class="p">(</span><span class="s1">&#39;auto&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">can_edit</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;canEdit&#39;</span><span class="p">),</span> <span class="kc">False</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">can_share</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;canShare&#39;</span><span class="p">),</span> <span class="kc">False</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">can_view_private_items</span> <span class="o">=</span> <span class="n">cloud_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;canViewPrivateItems&#39;</span><span class="p">),</span> <span class="kc">False</span><span class="p">)</span></div>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="fm">__repr__</span><span class="p">()</span>

    <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="s1">&#39;Calendar: </span><span class="si">{}</span><span class="s1"> from </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">owner</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">calendar_id</span> <span class="o">==</span> <span class="n">other</span><span class="o">.</span><span class="n">calendar_id</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">owner</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Owner of the calendar</span>

<span class="sd">        :rtype: str</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__owner</span>

<div class="viewcode-block" id="Calendar.update"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Calendar.update">[docs]</a>    <span class="k">def</span> <span class="nf">update</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Updates this calendar. Only name and color can be changed.</span>

<span class="sd">        :return: Success / Failure</span>
<span class="sd">        :rtype: bool</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">calendar_id</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">False</span>

        <span class="n">url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_url</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_endpoints</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;calendar&#39;</span><span class="p">))</span>

        <span class="n">data</span> <span class="o">=</span> <span class="p">{</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;name&#39;</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;color&#39;</span><span class="p">):</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">color</span><span class="o">.</span><span class="n">value</span>
                                        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">color</span><span class="p">,</span> <span class="n">CalendarColor</span><span class="p">)</span>
                                        <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">color</span><span class="p">)</span>
        <span class="p">}</span>

        <span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">con</span><span class="o">.</span><span class="n">patch</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>

        <span class="k">return</span> <span class="nb">bool</span><span class="p">(</span><span class="n">response</span><span class="p">)</span></div>

<div class="viewcode-block" id="Calendar.delete"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Calendar.delete">[docs]</a>    <span class="k">def</span> <span class="nf">delete</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Deletes this calendar</span>

<span class="sd">        :return: Success / Failure</span>
<span class="sd">        :rtype: bool</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">calendar_id</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">False</span>

        <span class="n">url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_url</span><span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_endpoints</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;calendar&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">calendar_id</span><span class="p">))</span>

        <span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">con</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="n">url</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">response</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">False</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">calendar_id</span> <span class="o">=</span> <span class="kc">None</span>

        <span class="k">return</span> <span class="kc">True</span></div>

<div class="viewcode-block" id="Calendar.get_events"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Calendar.get_events">[docs]</a>    <span class="k">def</span> <span class="nf">get_events</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">limit</span><span class="o">=</span><span class="mi">25</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">query</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">order_by</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">batch</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                   <span class="n">download_attachments</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">include_recurring</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Get events from the this Calendar</span>

<span class="sd">        :param int limit: max no. of events to get. Over 999 uses batch.</span>
<span class="sd">        :param query: applies a OData filter to the request</span>
<span class="sd">        :type query: Query or str</span>
<span class="sd">        :param order_by: orders the result set based on this condition</span>
<span class="sd">        :type order_by: Query or str</span>
<span class="sd">        :param int batch: batch size, retrieves items in</span>
<span class="sd">         batches allowing to retrieve more items than the limit.</span>
<span class="sd">        :param download_attachments: downloads event attachments</span>
<span class="sd">        :param bool include_recurring: whether to include recurring events or not</span>
<span class="sd">        :return: list of events in this calendar</span>
<span class="sd">        :rtype: list[Event] or Pagination</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">calendar_id</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="c1"># I&#39;m the default calendar</span>
            <span class="k">if</span> <span class="n">include_recurring</span><span class="p">:</span>
                <span class="n">url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_url</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_endpoints</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;default_events_view&#39;</span><span class="p">))</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_url</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_endpoints</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;default_events&#39;</span><span class="p">))</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">include_recurring</span><span class="p">:</span>
                <span class="n">url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_url</span><span class="p">(</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">_endpoints</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;events_view&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">calendar_id</span><span class="p">))</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_url</span><span class="p">(</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">_endpoints</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;get_events&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">calendar_id</span><span class="p">))</span>

        <span class="k">if</span> <span class="n">limit</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="n">limit</span> <span class="o">&gt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">protocol</span><span class="o">.</span><span class="n">max_top_value</span><span class="p">:</span>
            <span class="n">batch</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">protocol</span><span class="o">.</span><span class="n">max_top_value</span>

        <span class="k">if</span> <span class="n">batch</span><span class="p">:</span>
            <span class="n">download_attachments</span> <span class="o">=</span> <span class="kc">False</span>

        <span class="n">params</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;$top&#39;</span><span class="p">:</span> <span class="n">batch</span> <span class="k">if</span> <span class="n">batch</span> <span class="k">else</span> <span class="n">limit</span><span class="p">}</span>

        <span class="k">if</span> <span class="n">include_recurring</span><span class="p">:</span>
            <span class="n">start</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="n">end</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="k">if</span> <span class="n">query</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">query</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
                <span class="c1"># extract start and end from query because</span>
                <span class="c1"># those are required by a calendarView</span>
                <span class="k">for</span> <span class="n">query_data</span> <span class="ow">in</span> <span class="n">query</span><span class="o">.</span><span class="n">_filters</span><span class="p">:</span>
                    <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">query_data</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
                        <span class="k">continue</span>
                    <span class="n">attribute</span> <span class="o">=</span> <span class="n">query_data</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
                    <span class="c1"># the 2nd position contains the filter data</span>
                    <span class="c1"># and the 3rd position in filter_data contains the value</span>
                    <span class="n">word</span> <span class="o">=</span> <span class="n">query_data</span><span class="p">[</span><span class="mi">2</span><span class="p">][</span><span class="mi">3</span><span class="p">]</span>

                    <span class="k">if</span> <span class="n">attribute</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s1">&#39;start/&#39;</span><span class="p">):</span>
                        <span class="n">start</span> <span class="o">=</span> <span class="n">word</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;&#39;&quot;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)</span>  <span class="c1"># remove the quotes</span>
                        <span class="n">query</span><span class="o">.</span><span class="n">remove_filter</span><span class="p">(</span><span class="s1">&#39;start&#39;</span><span class="p">)</span>
                    <span class="k">if</span> <span class="n">attribute</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s1">&#39;end/&#39;</span><span class="p">):</span>
                        <span class="n">end</span> <span class="o">=</span> <span class="n">word</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;&#39;&quot;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)</span>  <span class="c1"># remove the quotes</span>
                        <span class="n">query</span><span class="o">.</span><span class="n">remove_filter</span><span class="p">(</span><span class="s1">&#39;end&#39;</span><span class="p">)</span>

            <span class="k">if</span> <span class="n">start</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="n">end</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;When &#39;include_recurring&#39; is True you must provide a &#39;start&#39; and &#39;end&#39; datetimes inside a Query instance.&quot;</span><span class="p">)</span>

            <span class="k">if</span> <span class="n">end</span> <span class="o">&lt;</span> <span class="n">start</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;When using &quot;include_recurring=True&quot;, the date asigned to the &quot;end&quot; datetime&#39;</span>
                                 <span class="s1">&#39; should be greater or equal than the date asigned to the &quot;start&quot; datetime.&#39;</span><span class="p">)</span>

            <span class="n">params</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;startDateTime&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="n">start</span>
            <span class="n">params</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;endDateTime&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="n">end</span>

        <span class="k">if</span> <span class="n">order_by</span><span class="p">:</span>
            <span class="n">params</span><span class="p">[</span><span class="s1">&#39;$orderby&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">order_by</span>

        <span class="k">if</span> <span class="n">query</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">query</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
                <span class="n">params</span><span class="p">[</span><span class="s1">&#39;$filter&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">query</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">params</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">query</span><span class="o">.</span><span class="n">as_params</span><span class="p">())</span>

        <span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">con</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">params</span><span class="o">=</span><span class="n">params</span><span class="p">,</span>
                                <span class="n">headers</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;Prefer&#39;</span><span class="p">:</span> <span class="s1">&#39;outlook.timezone=&quot;UTC&quot;&#39;</span><span class="p">})</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">response</span><span class="p">:</span>
            <span class="k">return</span> <span class="nb">iter</span><span class="p">(())</span>

        <span class="n">data</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">json</span><span class="p">()</span>

        <span class="c1"># Everything received from cloud must be passed as self._cloud_data_key</span>
        <span class="n">events</span> <span class="o">=</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">event_constructor</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span>
                                         <span class="n">download_attachments</span><span class="o">=</span>
                                         <span class="n">download_attachments</span><span class="p">,</span>
                                         <span class="o">**</span><span class="p">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_cloud_data_key</span><span class="p">:</span> <span class="n">event</span><span class="p">})</span>
                  <span class="k">for</span> <span class="n">event</span> <span class="ow">in</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;value&#39;</span><span class="p">,</span> <span class="p">[]))</span>
        <span class="n">next_link</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">NEXT_LINK_KEYWORD</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">batch</span> <span class="ow">and</span> <span class="n">next_link</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">Pagination</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">events</span><span class="p">,</span>
                              <span class="n">constructor</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">event_constructor</span><span class="p">,</span>
                              <span class="n">next_link</span><span class="o">=</span><span class="n">next_link</span><span class="p">,</span> <span class="n">limit</span><span class="o">=</span><span class="n">limit</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">events</span></div>

<div class="viewcode-block" id="Calendar.new_event"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Calendar.new_event">[docs]</a>    <span class="k">def</span> <span class="nf">new_event</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subject</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Returns a new (unsaved) Event object</span>

<span class="sd">        :rtype: Event</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">event_constructor</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> <span class="n">subject</span><span class="o">=</span><span class="n">subject</span><span class="p">,</span>
                                      <span class="n">calendar_id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">calendar_id</span><span class="p">)</span></div>

<div class="viewcode-block" id="Calendar.get_event"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Calendar.get_event">[docs]</a>    <span class="k">def</span> <span class="nf">get_event</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">param</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Returns an Event instance by it&#39;s id</span>

<span class="sd">        :param param: an event_id or a Query instance</span>
<span class="sd">        :return: event for the specified info</span>
<span class="sd">        :rtype: Event</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="n">param</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">None</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
            <span class="n">url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_url</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_endpoints</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;get_event&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">calendar_id</span><span class="p">,</span>
                                                        <span class="n">ide</span><span class="o">=</span><span class="n">param</span><span class="p">))</span>
            <span class="n">params</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="n">by_id</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_url</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_endpoints</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;get_events&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">calendar_id</span><span class="p">))</span>
            <span class="n">params</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;$top&#39;</span><span class="p">:</span> <span class="mi">1</span><span class="p">}</span>
            <span class="n">params</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">as_params</span><span class="p">())</span>
            <span class="n">by_id</span> <span class="o">=</span> <span class="kc">False</span>

        <span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">con</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">params</span><span class="o">=</span><span class="n">params</span><span class="p">,</span>
                                <span class="n">headers</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;Prefer&#39;</span><span class="p">:</span> <span class="s1">&#39;outlook.timezone=&quot;UTC&quot;&#39;</span><span class="p">})</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">response</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">None</span>

        <span class="k">if</span> <span class="n">by_id</span><span class="p">:</span>
            <span class="n">event</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">json</span><span class="p">()</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">event</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;value&#39;</span><span class="p">,</span> <span class="p">[])</span>
            <span class="k">if</span> <span class="n">event</span><span class="p">:</span>
                <span class="n">event</span> <span class="o">=</span> <span class="n">event</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">return</span> <span class="kc">None</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">event_constructor</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span>
                                      <span class="o">**</span><span class="p">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_cloud_data_key</span><span class="p">:</span> <span class="n">event</span><span class="p">})</span></div></div>


<div class="viewcode-block" id="Schedule"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Schedule">[docs]</a><span class="k">class</span> <span class="nc">Schedule</span><span class="p">(</span><span class="n">ApiComponent</span><span class="p">):</span>
    <span class="n">_endpoints</span> <span class="o">=</span> <span class="p">{</span>
        <span class="s1">&#39;root_calendars&#39;</span><span class="p">:</span> <span class="s1">&#39;/calendars&#39;</span><span class="p">,</span>
        <span class="s1">&#39;get_calendar&#39;</span><span class="p">:</span> <span class="s1">&#39;/calendars/</span><span class="si">{id}</span><span class="s1">&#39;</span><span class="p">,</span>
        <span class="s1">&#39;default_calendar&#39;</span><span class="p">:</span> <span class="s1">&#39;/calendar&#39;</span><span class="p">,</span>
        <span class="s1">&#39;get_availability&#39;</span><span class="p">:</span> <span class="s1">&#39;/calendar/getSchedule&#39;</span><span class="p">,</span>
    <span class="p">}</span>

    <span class="n">calendar_constructor</span> <span class="o">=</span> <span class="n">Calendar</span>
    <span class="n">event_constructor</span> <span class="o">=</span> <span class="n">Event</span>

<div class="viewcode-block" id="Schedule.__init__"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Schedule.__init__">[docs]</a>    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">parent</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">con</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Create a wrapper around calendars and events</span>

<span class="sd">        :param parent: parent for this operation</span>
<span class="sd">        :type parent: Account</span>
<span class="sd">        :param Connection con: connection to use if no parent specified</span>
<span class="sd">        :param Protocol protocol: protocol to use if no parent specified</span>
<span class="sd">         (kwargs)</span>
<span class="sd">        :param str main_resource: use this resource instead of parent resource</span>
<span class="sd">         (kwargs)</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">parent</span> <span class="ow">and</span> <span class="n">con</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;Need a parent or a connection but not both&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">con</span> <span class="o">=</span> <span class="n">parent</span><span class="o">.</span><span class="n">con</span> <span class="k">if</span> <span class="n">parent</span> <span class="k">else</span> <span class="n">con</span>

        <span class="c1"># Choose the main_resource passed in kwargs over parent main_resource</span>
        <span class="n">main_resource</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s1">&#39;main_resource&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="ow">or</span> <span class="p">(</span>
            <span class="nb">getattr</span><span class="p">(</span><span class="n">parent</span><span class="p">,</span> <span class="s1">&#39;main_resource&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="k">if</span> <span class="n">parent</span> <span class="k">else</span> <span class="kc">None</span><span class="p">)</span>

        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
            <span class="n">protocol</span><span class="o">=</span><span class="n">parent</span><span class="o">.</span><span class="n">protocol</span> <span class="k">if</span> <span class="n">parent</span> <span class="k">else</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;protocol&#39;</span><span class="p">),</span>
            <span class="n">main_resource</span><span class="o">=</span><span class="n">main_resource</span><span class="p">)</span></div>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="fm">__repr__</span><span class="p">()</span>

    <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="s1">&#39;Schedule resource: </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">main_resource</span><span class="p">)</span>

<div class="viewcode-block" id="Schedule.list_calendars"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Schedule.list_calendars">[docs]</a>    <span class="k">def</span> <span class="nf">list_calendars</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">limit</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">query</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">order_by</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Gets a list of calendars</span>

<span class="sd">        To use query an order_by check the OData specification here:</span>
<span class="sd">        http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/</span>
<span class="sd">        part2-url-conventions/odata-v4.0-errata03-os-part2-url-conventions</span>
<span class="sd">        -complete.html</span>

<span class="sd">        :param int limit: max no. of calendars to get. Over 999 uses batch.</span>
<span class="sd">        :param query: applies a OData filter to the request</span>
<span class="sd">        :type query: Query or str</span>
<span class="sd">        :param order_by: orders the result set based on this condition</span>
<span class="sd">        :type order_by: Query or str</span>
<span class="sd">        :return: list of calendars</span>
<span class="sd">        :rtype: list[Calendar]</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_url</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_endpoints</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;root_calendars&#39;</span><span class="p">))</span>

        <span class="n">params</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">if</span> <span class="n">limit</span><span class="p">:</span>
            <span class="n">params</span><span class="p">[</span><span class="s1">&#39;$top&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">limit</span>
        <span class="k">if</span> <span class="n">query</span><span class="p">:</span>
            <span class="n">params</span><span class="p">[</span><span class="s1">&#39;$filter&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">query</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">order_by</span><span class="p">:</span>
            <span class="n">params</span><span class="p">[</span><span class="s1">&#39;$orderby&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">order_by</span>

        <span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">con</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">params</span><span class="o">=</span><span class="n">params</span> <span class="ow">or</span> <span class="kc">None</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">response</span><span class="p">:</span>
            <span class="k">return</span> <span class="p">[]</span>

        <span class="n">data</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">json</span><span class="p">()</span>

        <span class="c1"># Everything received from cloud must be passed as self._cloud_data_key</span>
        <span class="n">contacts</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">calendar_constructor</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="p">{</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_cloud_data_key</span><span class="p">:</span> <span class="n">x</span><span class="p">})</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;value&#39;</span><span class="p">,</span> <span class="p">[])]</span>

        <span class="k">return</span> <span class="n">contacts</span></div>

<div class="viewcode-block" id="Schedule.new_calendar"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Schedule.new_calendar">[docs]</a>    <span class="k">def</span> <span class="nf">new_calendar</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">calendar_name</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Creates a new calendar</span>

<span class="sd">        :param str calendar_name: name of the new calendar</span>
<span class="sd">        :return: a new Calendar instance</span>
<span class="sd">        :rtype: Calendar</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">calendar_name</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">None</span>

        <span class="n">url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_url</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_endpoints</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;root_calendars&#39;</span><span class="p">))</span>

        <span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">con</span><span class="o">.</span><span class="n">post</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="p">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;name&#39;</span><span class="p">):</span> <span class="n">calendar_name</span><span class="p">})</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">response</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">None</span>

        <span class="n">data</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">json</span><span class="p">()</span>

        <span class="c1"># Everything received from cloud must be passed as self._cloud_data_key</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">calendar_constructor</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span>
                                         <span class="o">**</span><span class="p">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_cloud_data_key</span><span class="p">:</span> <span class="n">data</span><span class="p">})</span></div>

<div class="viewcode-block" id="Schedule.get_calendar"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Schedule.get_calendar">[docs]</a>    <span class="k">def</span> <span class="nf">get_calendar</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">calendar_id</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">calendar_name</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Returns a calendar by it&#39;s id or name</span>

<span class="sd">        :param str calendar_id: the calendar id to be retrieved.</span>
<span class="sd">        :param str calendar_name: the calendar name to be retrieved.</span>
<span class="sd">        :return: calendar for the given info</span>
<span class="sd">        :rtype: Calendar</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">calendar_id</span> <span class="ow">and</span> <span class="n">calendar_name</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s1">&#39;Provide only one of the options&#39;</span><span class="p">)</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="n">calendar_id</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">calendar_name</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s1">&#39;Provide one of the options&#39;</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">calendar_id</span><span class="p">:</span>
            <span class="c1"># get calendar by it&#39;s id</span>
            <span class="n">url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_url</span><span class="p">(</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_endpoints</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;get_calendar&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="n">calendar_id</span><span class="p">))</span>
            <span class="n">params</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="c1"># get calendar by name</span>
            <span class="n">url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_url</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_endpoints</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;root_calendars&#39;</span><span class="p">))</span>
            <span class="n">params</span> <span class="o">=</span> <span class="p">{</span>
                <span class="s1">&#39;$filter&#39;</span><span class="p">:</span> <span class="s2">&quot;</span><span class="si">{}</span><span class="s2"> eq &#39;</span><span class="si">{}</span><span class="s2">&#39;&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cc</span><span class="p">(</span><span class="s1">&#39;name&#39;</span><span class="p">),</span> <span class="n">calendar_name</span><span class="p">),</span>
                <span class="s1">&#39;$top&#39;</span><span class="p">:</span> <span class="mi">1</span><span class="p">}</span>

        <span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">con</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">params</span><span class="o">=</span><span class="n">params</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">response</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">None</span>

        <span class="k">if</span> <span class="n">calendar_id</span><span class="p">:</span>
            <span class="n">data</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">json</span><span class="p">()</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">data</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;value&#39;</span><span class="p">)</span>
            <span class="n">data</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">if</span> <span class="n">data</span> <span class="k">else</span> <span class="kc">None</span>
            <span class="k">if</span> <span class="n">data</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                <span class="k">return</span> <span class="kc">None</span>

        <span class="c1"># Everything received from cloud must be passed as self._cloud_data_key</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">calendar_constructor</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span>
                                         <span class="o">**</span><span class="p">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_cloud_data_key</span><span class="p">:</span> <span class="n">data</span><span class="p">})</span></div>

<div class="viewcode-block" id="Schedule.get_default_calendar"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Schedule.get_default_calendar">[docs]</a>    <span class="k">def</span> <span class="nf">get_default_calendar</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Returns the default calendar for the current user</span>

<span class="sd">        :rtype: Calendar</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_url</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_endpoints</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;default_calendar&#39;</span><span class="p">))</span>

        <span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">con</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">url</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">response</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">None</span>

        <span class="n">data</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">json</span><span class="p">()</span>

        <span class="c1"># Everything received from cloud must be passed as self._cloud_data_key</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">calendar_constructor</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span>
                                         <span class="o">**</span><span class="p">{</span><span class="bp">self</span><span class="o">.</span><span class="n">_cloud_data_key</span><span class="p">:</span> <span class="n">data</span><span class="p">})</span></div>

<div class="viewcode-block" id="Schedule.get_events"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Schedule.get_events">[docs]</a>    <span class="k">def</span> <span class="nf">get_events</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">limit</span><span class="o">=</span><span class="mi">25</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">query</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">order_by</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">batch</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                   <span class="n">download_attachments</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">include_recurring</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Get events from the default Calendar</span>

<span class="sd">        :param int limit: max no. of events to get. Over 999 uses batch.</span>
<span class="sd">        :param query: applies a OData filter to the request</span>
<span class="sd">        :type query: Query or str</span>
<span class="sd">        :param order_by: orders the result set based on this condition</span>
<span class="sd">        :type order_by: Query or str</span>
<span class="sd">        :param int batch: batch size, retrieves items in</span>
<span class="sd">         batches allowing to retrieve more items than the limit.</span>
<span class="sd">        :param bool download_attachments: downloads event attachments</span>
<span class="sd">        :param bool include_recurring: whether to include recurring events or not</span>
<span class="sd">        :return: list of items in this folder</span>
<span class="sd">        :rtype: list[Event] or Pagination</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">default_calendar</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">calendar_constructor</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="bp">self</span><span class="p">)</span>

        <span class="k">return</span> <span class="n">default_calendar</span><span class="o">.</span><span class="n">get_events</span><span class="p">(</span><span class="n">limit</span><span class="o">=</span><span class="n">limit</span><span class="p">,</span> <span class="n">query</span><span class="o">=</span><span class="n">query</span><span class="p">,</span>
                                           <span class="n">order_by</span><span class="o">=</span><span class="n">order_by</span><span class="p">,</span> <span class="n">batch</span><span class="o">=</span><span class="n">batch</span><span class="p">,</span>
                                           <span class="n">download_attachments</span><span class="o">=</span><span class="n">download_attachments</span><span class="p">,</span>
                                           <span class="n">include_recurring</span><span class="o">=</span><span class="n">include_recurring</span><span class="p">)</span></div>

<div class="viewcode-block" id="Schedule.new_event"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Schedule.new_event">[docs]</a>    <span class="k">def</span> <span class="nf">new_event</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">subject</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot; Returns a new (unsaved) Event object in the default calendar</span>

<span class="sd">        :param str subject: subject text for the new event</span>
<span class="sd">        :return: new event</span>
<span class="sd">        :rtype: Event</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">event_constructor</span><span class="p">(</span><span class="n">parent</span><span class="o">=</span><span class="bp">self</span><span class="p">,</span> <span class="n">subject</span><span class="o">=</span><span class="n">subject</span><span class="p">)</span></div>

<div class="viewcode-block" id="Schedule.get_availability"><a class="viewcode-back" href="../../api/calendar.html#O365.calendar.Schedule.get_availability">[docs]</a>    <span class="k">def</span> <span class="nf">get_availability</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">schedules</span><span class="p">,</span> <span class="n">start</span><span class="p">,</span> <span class="n">end</span><span class="p">,</span> <span class="n">interval</span><span class="o">=</span><span class="mi">60</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns the free/busy availability for a set of users in a given time frame</span>
<span class="sd">        :param list schedules: a list of strings (email addresses)</span>
<span class="sd">        :param datetime start: the start time frame to look for available space</span>
<span class="sd">        :param datetime end: the end time frame to look for available space</span>
<span class="sd">        :param int interval: the number of minutes to look for space</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">url</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build_url</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_endpoints</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;get_availability&#39;</span><span class="p">))</span>

        <span class="n">data</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;startTime&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_build_date_time_time_zone</span><span class="p">(</span><span class="n">start</span><span class="p">),</span>
            <span class="s1">&#39;endTime&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_build_date_time_time_zone</span><span class="p">(</span><span class="n">end</span><span class="p">),</span>
            <span class="s1">&#39;availabilityViewInterval&#39;</span><span class="p">:</span> <span class="n">interval</span><span class="p">,</span>
            <span class="s1">&#39;schedules&#39;</span><span class="p">:</span> <span class="n">schedules</span>
        <span class="p">}</span>

        <span class="n">response</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">con</span><span class="o">.</span><span class="n">post</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">response</span><span class="p">:</span>
            <span class="k">return</span> <span class="p">[]</span>

        <span class="n">data</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;value&#39;</span><span class="p">,</span> <span class="p">[])</span>

        <span class="c1"># transform dates and availabilityView</span>
        <span class="n">availability_view_codes</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s1">&#39;0&#39;</span><span class="p">:</span> <span class="s1">&#39;free&#39;</span><span class="p">,</span>
            <span class="s1">&#39;1&#39;</span><span class="p">:</span> <span class="s1">&#39;tentative&#39;</span><span class="p">,</span>
            <span class="s1">&#39;2&#39;</span><span class="p">:</span> <span class="s1">&#39;busy&#39;</span><span class="p">,</span>
            <span class="s1">&#39;3&#39;</span><span class="p">:</span> <span class="s1">&#39;out of office&#39;</span><span class="p">,</span>
            <span class="s1">&#39;4&#39;</span><span class="p">:</span> <span class="s1">&#39;working elsewhere&#39;</span><span class="p">,</span>
        <span class="p">}</span>
        <span class="k">for</span> <span class="n">schedule</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="n">a_view</span> <span class="o">=</span> <span class="n">schedule</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;availabilityView&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)</span>
            <span class="n">schedule</span><span class="p">[</span><span class="s1">&#39;availabilityView&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span><span class="n">availability_view_codes</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">code</span><span class="p">,</span> <span class="s1">&#39;unkknown&#39;</span><span class="p">)</span> <span class="k">for</span> <span class="n">code</span> <span class="ow">in</span> <span class="n">a_view</span><span class="p">]</span>
            <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">schedule</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;scheduleItems&#39;</span><span class="p">,</span> <span class="p">[]):</span>
                <span class="n">item</span><span class="p">[</span><span class="s1">&#39;start&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_date_time_time_zone</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;start&#39;</span><span class="p">))</span>
                <span class="n">item</span><span class="p">[</span><span class="s1">&#39;end&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_date_time_time_zone</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;end&#39;</span><span class="p">))</span>

        <span class="k">return</span> <span class="n">data</span></div></div>
</pre></div>

           </div>
           
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2018, Narcolapser

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/language_data.js"></script>
    

  

  <script type="text/javascript" src="../../_static/js/theme.js"></script>

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>